Skip to Content

There was a requirement to consume a RESTful web service which accepts payload data in CSV format and the data was received in SAP PI from ECC system through proxy. Data can be sent through the REST adapter in either XML or JSON format, REST adapter does not provide any other data format.

Sample CSV format:




In order to send data in a format other than XML or JSON through REST adapter we followed the below steps:

1)      Conversion of XML data to CSV

For converting the data from XML to CSV format we used the Message Transformation Bean

Sample XML data in which was received in SAP Pi from ECC:

<?xml version="1.0" encoding="UTF-8"?>

We used the following settings for MTB for converting XML to CSV:

Module Key Parameter Name Parameter Value
xmltocsv Transform.Class
xmltocsv Transform.ContentType application/json;charset=utf-8
xmltocsv xml.CustomerDetails.endSeparator ‘nl’
xmltocsv xml.CustomerDetails.fieldSeparator ,
xmltocsv xml.conversionType StructXML2Plain
xmltocsv xml.recordsetStructure CustomerDetails

Note : The content type was set to application/json in order to send the CSV data in the JSON format

2)      REST channel configuration for setting the Data Format

As the default data conversion of REST adapter was not required so we used the following settings to send the CSV data:


Set the Data Format as “JSON” and Character Set Name as “UTF-8”.

The “Convert XML Payload to JSON” and “Strip Operation from Message (Outer Element)” options need to be unchecked so that REST adapter does not transform the data.

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Former Member

    I can’t seem to make this work. The REST Adapter is giving me the error

    exception caught with cause Unable to parse XML message content: “Content is not allowed in prolog.”

    It seems the adapter is excpecting the XML standard prolog <?xml version=”1.0″ encoding=”UTF-8″?>

    But obviously with the Message Transformation bean to csv this is removed.

    I’m using SAP PO 7.5

    Any ideas?

    PS: I was able to do this same thing with the SOAP rcv adapter, but I need some other features that are only available in the REST Adapter.

    Thanks in advance.

    1. Former Member

      OK. After creating an incident directly with SAP. I got my response.

      I cannot do a MessageTransform and them expect to use the  Pattern Variable Replacement. It sound logical.

      Here is their response:

      The error message you have encountered is caused from the configuration you have set up.
      In Rest Receiver channel in tab ‘REST URL’ you have configured ‘Pattern Variable Replacement’ with an XPath expression. The problem is that when the REST Adapter try to search for this XPath expression, it already has payload in CSV format, which try to parse to XML to find the required XPath. And here it fails.
      This means that you cannot extract any XPath or JSON expression because the structure of the payload is CSV and the REST adapter does not supposed to work with this kind of structure.
      The only way in this case to get this ‘sessionId’ element value is to pass it to the REST Receiver channel as Dynamic attribute of the XI message/payload/.

      Best regards!



Leave a Reply