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!
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?
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?
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?
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.
% 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
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!
Maybe also check you are not running into the ESAPI validation issue as earlier. https://support.ptc.com/help/thingworx/platform/r10.0/en/#page/ThingWorx/Help/Installation/ConfiguringESAPIValidatorSettings.html
Hello @MA8731174 ,
The basic issue you have encountered. The Percent Character (ie %), is allowed in the data of the XML. The issue with passing the XML data in a URL. The allowed characters in the URL does not allow the "%" character. The data needs to be encoded so that it can be passed. The change for the % character is to replace with "&percent;". If you are receiving the data from an SAP Rest API it should be encoded. The receiving service will need to undo the encoding to get the original XML.
Does this help?
Regards,
Pehowe
Hi Pehowe,
thank you for the explanation.
In my case, the XML is actually being sent in the body of the API request, not in the URL.
So I just wanted to clarify that the “%” character is only part of the XML content inside the request body.
Does the same encoding rule still apply when the XML is not passed through the URL?
@MA8731174 I'd say at this stage you have three options:
I just did some testing, and realized that if you encode your payload using UTF-8 encoder, it works. Here's an example in Java:
String body = "<data><test>this is a % test</test></data>";
body = URLEncoder.encode(body, "UTF8"); // Becomes "%3Cdata%3E%3Ctest%3Ethis+is+a+%25+test%3C%2Ftest%3E%3C%2Fdata%3E"
If they can do it on the calling side -- you have it fixed.
I'm still not sure why they decided to mandate UTF-8 encoding for the payload on ThingWorx side, but at least this doesn't look like a random bug anymore.
I have tested it with like <tage>%20></tage> as 20 is an ASCII for percentage sign and now the url works..
now the question is like SAP team do not want to do encoding for me and i have to handle this on my own. where i can prepare the xml data first because on thingworx its not possible to prepare the xml first and then get it. i am thinking to make a preparation of xml data from another server in a company and then send to thingworx but i am still not sure that should i request again to SAP team for it... please give me your opinion on this matter
Hello @MA8731174 ,
I did a little research, I believe this is the answer you are looking for when using POSTMAN.

Pleases review "Send parameters and body data with API requests in Postman"
Let me know if it answers your questions
Regards,
Pehowe
Hello @PEHOWE,
thank you for your response and for checking this.
I just wanted to clarify that in my case the issue is not related to the URL parameters or URI encoding.
The actual problem occurs in the request body.
When I manually encode the body content (e.g., using EncodeURIComponent), the request works correctly and percentage characters (%) are preserved as expected.
However, when I send the body without encoding, Postman throws a parsing error.
So the behavior is not about URL encoding, but how Postman handles raw body content when certain special characters are included.
The postParameter = content at the end of the URL is fine — the real challenge is ensuring the body is interpreted correctly.
Just wanted to clarify this difference for the context of my issue. It seems like a thingworx error.
Regards,
Hello @MA8731174 ,
If you have a test case which shows this issue, I would be happy to get it reviewed.
It is important to have the version numbers of the application to allow validation of the issue and testing of a workaround or resolution.
ThingWorx Version
POSTMAN Version
Server Type and Version (Linux , Windows)
If you can provide the POSTMAN configuration and any customization needed on ThingWorx side I will get the issue reviewed.
Regards,
Pehowe
hello @PEHOWE
Thingworx version 9.3.7
Postman 11.75.1
server type-> windows
Please create a service on thingworx and choose output as xml and input param for me i call it content is also of xml type.
result = content
after that you can give a xml in service and u get output same as xml what u give in input. then you can use that service as api in post and give it content of xml and use percentage sign in it and you will not get output... please dont forget to use postParameter=content in the end of the link otherwise it does not take xml.
please test it ... i am excited to see results as i have already talked with one ptc guy and he has tried it for an hour but still could not get this error resolved...
Hi @PEHOWE
Steps to reproduce our issue
We would like to create a ThingWorx service which is called by an external system that only can handle XML. This external system sends a HTTP POST Request to ThingWorx with a fixed data format in the body that we cannot change.
Therefore, we created a ThingWorx service for testing with an input parameter named "content" of type "XML". The output of this service is also set to type "XML".
The source code inside this test service consists only of following line: "let result = content;". So, the input provided via the "content" parameter is simply written into the result.
Because the provided xml format from the external system is fixed and we could not adapt it (like wrapping it in a JSON), it is necessary to assign the whole data of the HTTP request body to the "content" parameter. To solve this issue, we found out, that "?postParameter=content" has to be added to the request URL. In addition, we set the "Content-Type" and "Accept" headers to "text/xml".
In the most cases, this approach works as expected. (The XML provided in the HTTP POST request body is returned in the response body.)
But as soon as a percent sign (%) is included in the XML content sent to ThingWorx, the server returns the error code 406: "Unable To Parse XML Request"
As far as we know, the percent sign is not a special character in XML. So this behavior should not occur.
We assume that this error is thrown before any JavaScript service execution is done. So we cannot handle it on ThingWorx side.
We found out that if we replace all percent signs by "%25", everything works as expected.
So following texts in the request body work: "<test>test text</test>" or "<test>test%25text</test>"
However, this text does not work: "<test>test%text</test>"
But as mentioned before, we cannot change the source xml format which is sent to our ThingWorx server. So, this is not a feasible solution.
Could you please take a look at this problem? How can we send this text in the body of the HTTP request so ThingWorx accepts it "<test>test%text</test>"
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
Hello @MA8731174 ,
Here is the sample services.
Let me know if you have any questions
Regards,
Pehowe
