Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
Showing results for 
Search instead for 
Did you mean: 

In this blog, we have a scenario where data sent from SAP to an external system is in the form of Proxy To REST. An external system provides us with a REST API. We will send a request to this API using the POST method. In the request sent according to the API of the external system, there are integer values corresponding to the IDs field. These values, after passing through the XML type at the mapping step and transitioning to the converter step in the adapter, have double quotes added to them by the adapter. Consequently, the service returns a 400 bad request response.

Typically, these fields within the array correspond to an IDs field. In other words:


In contrast, during triggering, they are sending all integer values within an array with commas between them, like so;


As a result, the adapter incorrectly interprets them as separate key-value pairs with the key "IDs", leading to the addition of double quotes during JSON conversion.



Firstly, defining the IDs field as an integer in the adapter did not work because the PO (Process Orchestration) converts this request to a string due to the commas between the values in the sent request.

When we inspect the logs, we observe that in the step where the adapter converts to JSON, it adds double quotes as follows:

Receiver json.png

Step 1. XSLT

I decided not to perform the conversion operation in the adapter because I believe the error stems from that conversion process. By default, the structure outputted from the mapping step is in XML format. If we convert this structure to JSON in the mapping step and specify that this structure is an array, the issue will be resolved. To achieve this, I have written an XSLT.



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="text" encoding="UTF-8"/>
	<xsl:template match="/">
	<!-- Process the IDs element -->
	<xsl:template match="IDs">
		<!-- Convert XML content directly to JSON -->
		<xsl:value-of select="."/>
	<!-- Match the delimiters to add commas -->
	<xsl:template match="IDs[position() &gt; 1]">
		<xsl:value-of select="."/>




Step 2. XSLT Import in PO

Afterward, I imported this XSLT file into PO as an imported archive.



Step 3. XSLT Mapping

Then, in the operation mapping step, I provided the imported XSLT file to the request mapping.



Step 4. REST Receiver Adapter

In a default proxy to REST scenario, XML is expected to be output from the after mapping step, so we usually check the option "Convert XML payload to JSON" in the adapter. However, in our scenario, we are sending a JSON structure from the mapping step to the adapter. Therefore, we will not check this option. Instead, we will simply select JSON as the Data Format to indicate that our request is in JSON format.



Step 5. Testing

After completing all the PO steps, our service is now ready for testing. We can send a payload from the "Send Message" step to proceed.





It is very helpful, thank you for sharing.


@Han_Soylu i'm glad to hear that! 🙂

0 Kudos

It is really useful and clear,thank you very much.

0 Kudos

@MF3 MF3 Thank you so much 🙂

Labels in this area