Skip to main content
1-Visitor
Oct 17, 2018 6:25 AM UTC
Question

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

20-Turquoise
Oct 18, 2018 1:11 PM UTC

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

Translate
1-Visitor
Oct 24, 2018 1:32 PM UTC

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

Translate
20-Turquoise
Nov 2, 2018 1:57 PM UTC

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.

 

 

Translate