cancel
Showing results for 
Search instead for 
Did you mean: 

Backward slash inserted ahead of forward slash in adapter

Former Member
0 Kudos

I have a REST to ECC synchronous scenario.

I am sending a url in the response message from ECC

this is the url http://host:port/RESTAdapter/DFT/Employee/100001

the last can change accordingly

However the adapter sends it like this:

http:\/\/host:port\/RESTAdapter\/DFT\/Employee\/100001

A backward slash is inserted ahead of every forward slash in the url

Accepted Solutions (1)

Accepted Solutions (1)

engswee
Active Contributor

Hi Midhun

I'm not sure why the sender REST channel adds the back slash when converting the response from XML to JSON.

I tried executing a conversion using my custom XML to JSON module and it does not produce extra back slashes.

You might want to open a call to SAP to ask them on this.

The only other alternative I can think of is to add an additional Java mapping in your OM after the response mapping. The Java mapping would convert the XML to JSON, so you don't use the standard channel's conversion.

Rgds

Eng Swee

Former Member
0 Kudos

Hi Eng

JSON doesn't support forward slashes in it's payload. I guess you converted the payload without any forward slashes in payload. I have url s in payload. Those urls have forward slashes and the forward slashes in url are escaped.

It is a synchronous scenario. I have request mapping and response mapping. I don't know how to add another java mapping. Could you elaborate on that a bit? I think it is  a better option than adapter module development

Regards

engswee
Active Contributor
0 Kudos

I converted using a URL in the payload.

Input

Output

You can add a Java mapping as a second step of the response mapping in your OM - refer below.

For the Java mapping, you can try to go JSON in Java libraries - that's the library I used for my adapter module and it converts without the additional backslash as shown above.

Rgds

Eng Swee

Former Member
0 Kudos

Hi Eng

I am also not getting backward slash when I test from SOAP UI or POSTMAN. When the webservice receive the data,they are getting backward slash. when I test with POSTMAN, my payload is just fine.

So under the Message Mapping, we have to create a  new Java Mapping and write the code to convert the entire message type to JSOn right. And this mapping should be saved as external defnition and added, right

engswee
Active Contributor
0 Kudos

You mean "Under Operation Mapping" - yes. Develop the Java mapping and import as a Jar into ESR, then select it in your OM.

Former Member
0 Kudos

Hi Eng

do i have to convert the xml into JSON object or JSON array?

Regards

engswee
Active Contributor
0 Kudos

Fields/nodes with max occurrence 1 will be JSON object, those with unbounded max occurrence will be JSON array.

Former Member
0 Kudos

Hi Eng

This suggestion worked for me

I created a Java mapping, imported the Java mapping jar along with json.org jar into the message mapping and it's working fine

thanks for the solution

Answers (2)

Answers (2)

manoj_khavatkopp
Active Contributor
0 Kudos

Hi Midhun,

Those back slash are escape characters i guess you are converting XML to JSON?

This is where it is being modified.

Br,

Manoj

Former Member
0 Kudos

Yeah, it is. I am converting xml to json..

JSON doesn't support forward slash?

manoj_khavatkopp
Active Contributor
0 Kudos

i am not so sure of how to handle this in Rest adapter but you can ask the third party only to have logic to remove those slash.

maheswarareddykonda
Active Contributor
0 Kudos

i am not sure that why, though if you want to just forward slash then, use replace function in mapping level.

Former Member
0 Kudos

Hi Mahesh

iN the mapping, I am adding it

I am concatanating http://host:port/RESTAdapter/DFT/Employee/ with the employee number send by RFC and sending it as href value.

It is not a mapping issue, I tested in mapping. The adapter is adding that.

REST does a get call, ECC responds back with data, and I pass it to the REST synchronous sender channel.