cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

GetXML is giving error for SAP odata URL

SaranKarthick
16-Pearl

GetXML is giving error for SAP odata URL

Hi Developers,

 

I'm trying to fetch xml content from this SAP odata ProductSet URL. I had used "GetXML" content loader function

for this and got the below error:

 

<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" headers="accept=application/xml"><code>005056A509B11ED19BEB6513AA349DA5</code><message xml:lang="en">The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request</message></error>

 The service code is as follows:

 

var headers = {
    "accept": "application/xml"
  }

var params = {
	proxyScheme: undefined /* STRING */,
	headers: headers /* JSON */,
	ignoreSSLErrors: "true" /* BOOLEAN */,
	useNTLM: undefined /* BOOLEAN */,
	workstation: undefined /* STRING */,
	useProxy: undefined /* BOOLEAN */,
	withCookies: undefined /* BOOLEAN */,
	proxyHost: undefined /* STRING */,
	url: "https://sapes5.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/ProductSet" /* STRING */,
	timeout: undefined /* NUMBER */,
	proxyPort: undefined /* INTEGER */,
	password: <SAP Password> /* STRING */,
	domain: undefined /* STRING */,
	username: <SAP ES5 Demo System Username> /* STRING */
};

// result: XML
var result = Resources["ContentLoaderFunctions"].GetXML(params);

In the browser the above mentioned URL returns the XML content, so i don't suspect any firewall issue. 

 

I tried the "GetJSON" function for the same URL but with this "?$format=json"string appended to it and the json is returned as expected.

The service code for the GetJSON is as follows:

var headers = {
    "accept": "application/xml"
  }

var params = {
	proxyScheme: undefined /* STRING */,
	headers: headers /* JSON */,
	ignoreSSLErrors: true /* BOOLEAN */,
	useNTLM: undefined /* BOOLEAN */,
	workstation: undefined /* STRING */,
	useProxy: undefined /* BOOLEAN */,
	withCookies: undefined /* BOOLEAN */,
	proxyHost: undefined /* STRING */,
	url: "https://sapes5.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/ProductSet?$format=json" /* STRING */,
	timeout: undefined /* NUMBER */,
	proxyPort: undefined /* INTEGER */,
	password: <SAP Password> /* STRING */,
	domain: undefined /* STRING */,
	username:<SAP Username> /* STRING */
};

// result: JSON
var result = Resources["ContentLoaderFunctions"].GetJSON(params);

Is the params not properly used for GetXML?

 

Regards,

Saran

6 REPLIES 6

You may want to try parsing it into a datatable as described in the following article: https://www.ptc.com/en/support/article?n=CS218242

Hi @posipova,

 

Thanks for your reply. I had followed the article you had shared. The first part of the article is to get the XML content and then we'll proceed to the steps where we'll show it in a infotable format. I'm having trouble in the first step itself.

 

It seems that the service GetXML is failing for only the URL "https://sapes5.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/ProductSet" i had given. Its working with other common URL's like "https://www.w3schools.com/xml/simple.xml"

But i'm curious how the same URL which was not working for GetXML is working properly for GetJSON.

 

If there is an issue with the URL or the parameters then both the services shouldn't be working. Is this issue related to SAP or Thingworx?

 

Regards,

Saran

This looks like it might be a SAP issue. I've looked through our knowledgebase and seems like people have experienced similar situations, where it was determined to be a SAP problem.

 

 

Hi @posipova,

 

Thanks for your reply.

 

I'm currently using a SAP Gateway - Demo System (ES5) for testing. I'm new to SAP so if you could elaborate on the SAP issue it would be useful.

 

Regards,

Saran

Hi @posipova,

 

Thanks for your help. Will check it out and let you know

 

Regards,

Saran

Announcements


Top Tags