Skip to Content

PI Rest Sender adapter, how to omit escape characters in payload

Hello Experts,

In the payload, I have character (forward slash) "/", but while converting it from XML to JSON, the sender REST adapter is appending "\" (backward slash) to it.

Need help in eliminating the "\" (backward slash) from the resulting JSON format.

XML format

<ServiceType>CPINPUSHREQ</ServiceType>
<Signature>wcIc4ooVKxfBGT0tpZJMAkIc2xEKYDrgNXvvJheeLXC2inadHGpIVQQh8N0uj3b/uEwQowOD4rIeb3zHn4in0amePt73TziUTuzeZyHO+3J5ADDs8AlJ/oYpYW5IfgRopejWSshCBXsob+7WkS1D3GLFg2L7VKumf4xz5cjTDR3vTMA7QPk6ogoe5kX0w5baJtprzNUR2K1/5P6YmWSQBUVaYOlewviAbw4BCvhCLNn67WhskPEBzRc3vqlkPK/cdX+8gsgTqOLWoBMUvaFCNwewpOSZ4gtdGwUtjx9JjWKHV40lWA6wwmay/9USx+cRgfUiID9P8Y6F2iLc7tCt6g==</Signature>

resulting JSON format

{"System":"SAPTEST","ServiceType":"CPINPUSHREQ","Signature":"wcIc4ooVKxfBGT0tpZJMAkIc2xEKYDrgNXvvJheeLXC2inadHGpIVQQh8N0uj3b\/uEwQowOD4rIeb3zHn4in0amePt73TziUTuzeZyHO+3J5ADDs8AlJ\/oYpYW5IfgRopejWSshCBXsob+7WkS1D3GLFg2L7VKumf4xz5cjTDR3vTMA7QPk6ogoe5kX0w5baJtprzNUR2K1\/5P6YmWSQBUVaYOlewviAbw4BCvhCLNn67WhskPEBzRc3vqlkPK\/cdX+8gsgTqOLWoBMUvaFCNwewpOSZ4gtdGwUtjx9JjWKHV40lWA6wwmay\/9USx+cRgfUiID9P8Y6F2iLc7tCt6g==","Payload":{"CPIN":"10341234567890","ExpDt":"20170720","TotalAmt":"200","PayerName":"abc","ChallanDtls":[{"AcntID":"101001001","Amount":"200","AdminZone":"10"},{"AcntID":"101001001","Amount":"200","AdminZone":"10"}]}}

Regards,

Sushant

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Dec 04 at 11:02 AM

    Hello Guys,

    This was solved using FormatConversionBean, using the below link

    https://blogs.sap.com/2015/03/25/formatconversionbean-one-bean-to-rule-them-all/

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 02 at 08:02 PM

    Hi Sushant,

    I believe you will have to use a second java mapping. Check this link below.

    https://archive.sap.com/discussions/thread/3845451

    Thanks,

    Piyush

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Piyush,

      can you help me with the Java mapping.

      I have used the code specified in the blog but I need some help with the Java mapping

      Sushant

  • Nov 02 at 08:11 AM

    Hi Sushant ,

    This is the standard behavior of Jettison library used in REST adapter, this cannot be changed there is SAP note on the same which explains this.

    But however when third-party converts back this JSON to XML the character gets removed so that should not be an issue.

    Br,

    Manoj

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Manoj,

      Thanks for the reply

      Actually third party is accepting the message in JSON format and conversions are not taking place at their end.

      I want to know that how can we handle this in PI.

      Regards,

      Sushant

  • Nov 08 at 06:27 AM

    Hello Experts,

    Can someone please help me with a EJB or some other mechanism to handle the backslash in the payload getting added due to the conversions.

    Request for prompt replies, please help.

    Regards,

    Sushant

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 16 at 02:59 PM

    Hi,

    It can be achieved by the string#replace functionality in JAVA

    something like this

    String noSlashes = input.replace("\\", "");

    More info below in the Java documentation

    https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#replace%28java.lang.CharSequence,%20java.lang.CharSequence%29

    Thanks,

    Piyush

    Add comment
    10|10000 characters needed characters exceeded