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

ThingWorx Navigate is now Windchill Navigate Learn More

Translate the entire conversation x

How to receive and process XML data in a ThingWorx service (via external SAP API call)?

MA8731174
16-Pearl

How to receive and process XML data in a ThingWorx service (via external SAP API call)?

 Hi everyone,

 

I’m working on a use case where our SAP team wants to send data to ThingWorx via an HTTP API call. They will post the data as XML, and ThingWorx should receive it in a service, parse it, and store the information in a DataTable or Dataset.

 

However, I’m not sure how to receive the XML payload properly inside a ThingWorx service. When SAP calls my service endpoint, I don’t see any way to directly access the raw XML content — it’s either not recognized or comes as an empty input parameter.

 

What’s the correct approach to handle this in ThingWorx?

 

Specifically:

How can I receive XML from an external system in a ThingWorx service?

Do I need to configure a specific Content-Type header (like application/xml)?

 

 

If anyone has done SAP → ThingWorx integration with XML payloads, I’d really appreciate an example or best-practice recommendation.

 

Thanks in advance! 

 

12 REPLIES 12

We solved it by setting the Content-Type to text/xml  and accept  text/xmland creating a ThingWorx service with an input parameter content of type XML.

 

In the REST API call, I added the flag ?postParameter=content — and now the XML payload from SAP is correctly received inside the service.

I am facing another issue now while processing the XML payload received from SAP. There are several tags (around 4–5) that contain the % character. When these tags include the % sign, the request fails with an “unable to parse XML request” error.

I am already sending the correct headers:

  • Accept: text/xml

  • Content-Type: text/xml

If the % character is removed from the payload, the request is processed successfully and I receive the expected XML response.

Could anyone please advise how we should handle or encode the % character in the XML so that the request can be parsed correctly?

Rocko
19-Tanzanite
(To:MA8731174)

Tagnames in XML can't contain the % character per definition. That problem should be solved at the source, not the destination.

I did not find that % sign should not be in the XML. I have seen that operator like & must not be in the xml in the specifications of the XML. Would you please let me know more about it? 

 

So you meant that i should inform SAP team that not to send me % sign in the XML?

Rocko
19-Tanzanite
(To:MA8731174)

You wrote about tags containing "%". Like <AA%AA></AA%AA> This is not allowed. 

% in the payload is allowed.

its in payload actually. then what can be the solution to this issue?

Rocko
19-Tanzanite
(To:MA8731174)

Hard to say. You could dig into finding out where the % gets removed, you could try to introduce encoding or check if the encoding is correct (UTF-8?).

You could also try to switch from text/xml to text/plain and transform/parse the XML yourself.

403 forbidden error when i try to use text/plain only without UTF-8.

 

and with UTF-8 text/xml is also error unable to parse xml request.

 

with UTF-8  text/plain 403 forbidden.

 

 

One of the example from my XML --> <Tagging>%</Tagging>

% is an XML entity, try encoding it as  &percnt; on SAP side.

See https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references


Vilia (my company) | GitHub | LinkedIn

With CDATA it works as below

![CDATA[&percnt;]] 

 

 

but if i write &percnt in a tag then error as below

406 not acceptable

 

I ll contact SAP team about it Thank you!

Rocko
19-Tanzanite
(To:MA8731174)

Announcements


Top Tags