cancel
Showing results for 
Search instead for 
Did you mean: 

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

SushantShinde
Advisor
Advisor
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

SushantShinde
Advisor
Advisor

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/

JaySchwendemann
Active Contributor
0 Kudos

Hi Shushant,

first of all, thanks for coming back and stating how you solved the issue (this is unfortunately not done by everyone, raising a question)

However, could you clarify how exactly you dealt with this problem? I'm in the same situation right now, trying to integrate with Jira and getting "\\r\\n" for carriage return / line feed.

Many thanks and kind regards

Jens

SushantShinde
Advisor
Advisor
0 Kudos

Hello Jens,

You can follow the above link shared, just get the EAR imported in you PO system and then just configure the module parameters in channel, it will be done, give it a try. If further help is needed, you can buzz me here.

Regards,

Sushant

former_member223432
Participant
0 Kudos

HI Sushant,


I am also facing the same issue. Could you please let me know how you fixed it? i am on PO 7.5 . do i need to import the EAR in po system. could you please let me know how did you configure the module parameters here?

thanks

Smith

Answers (4)

Answers (4)

former_member593648
Active Participant
0 Kudos

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,%20...

Thanks,

Piyush

former_member223432
Participant
0 Kudos

HI Piyush,

I am working on Proxy to REST sync interface. I have few input fields which has value '/' in it ex: ( AOUS/12 and some date fields(23/04/2020).

at the JSON output payload it is coming as AOUS\/12 and dates are coming as 23\/04\/2020.

there is an addition of '\' in between. I tried to declare the field as "string" in custom xml/JSON coversion rules. but still its not working. i also tried to declare the field as "Date" in the datatype but still no luck because in the mapping its correctly populated.

the issue is coming at the REST channel while converting XML to JSON format.

Can you please help me how to get rid of this extra '\' at the channel level. if you have a JAVA mapping cod for the same, can you please share it.

thanks

Smith

SushantShinde
Advisor
Advisor
0 Kudos

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

former_member593648
Active Participant
0 Kudos

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

SushantShinde
Advisor
Advisor
0 Kudos

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

manoj_khavatkopp
Active Contributor
0 Kudos

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

SushantShinde
Advisor
Advisor
0 Kudos
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