Skip to main content
16-Pearl
November 26, 2025
Solved

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

  • November 26, 2025
  • 2 replies
  • 1508 views

 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! 

 

Best answer by PEHOWE

Hello @MA8731174 ,
I have reviewed your issue with the Support team.
It appears that when the XML is input into ThingWorx it is being parsed. This parse is what is causing the issue. One solution would be to have the source encode the XML. You have indicated that is not an acceptable solution.

A work around would be to construct a JSON which contains the XML. 
One method of doing this would be to create a Micro Service which accepts the XML and performs the encoding of Percent and then pass the value ThingWorx.

I have an  export of the testing services from POSTMAN, and ThingWorx export of the thing used in our testing. I will be attaching them to a separate post

Please let me know if you have any questions

 

Regards,

Pehowe

2 replies

MA873117416-PearlAuthor
16-Pearl
November 26, 2025

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.

MA873117416-PearlAuthor
16-Pearl
November 27, 2025

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
November 27, 2025

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

18-Opal
November 27, 2025

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

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

MA873117416-PearlAuthor
16-Pearl
November 28, 2025

With CDATA it works as below

![CDATA[%]] 

 

 

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
November 28, 2025