cancel
Showing results for 
Search instead for 
Did you mean: 

SAP PI 7.40 adapter REST receive - conversion XML to JSON

Former Member
0 Kudos

Hi the community,

we are in SAP PI7.40 .

In an adapter REST receive, I want to convert XML to JSON.

XML format :

<ns1:MT0034_Request_SetInstalledParts xmlns:ns1="http://toyota.be/xi/TME/WLTP">
<parts>
<partnumber>p1</partnumber>
<genuineFlag>x</genuineFlag>
<installedFlag>x</installedFlag>
<installationDate>2017-02-24</installationDate>
<quantity>4</quantity>
</parts>
<parts>
<partnumber>p2</partnumber>
<genuineFlag>x</genuineFlag>
<installedFlag>x</installedFlag>
<installationDate>2017-02-25</installationDate>
<quantity>3</quantity>
</parts>
</ns1:MT0034_Request_SetInstalledParts>

to JSON format

[{"partnumber":"p1","genuineFlag":"x","installedFlag":"x","installationDate":"2017-02-24","quantity":4},{"partnumber":"p2","genuineFlag":"x","installedFlag":"x","installationDate":"2017-02-25","quantity":3}]

In the adapter , If I check "Strip Operation from Message (Outer Element)", I receive an error HIERARCHY_REQUEST_ERR because in my case there are many XML <parts> .

I unchecked that filed and I checked "Strip Outer Element" and in that case the JSON is

{"parts":[{"partnumber":"p1","genuineFlag":"x","installedFlag":"x","installationDate":"2017-02-24","quantity":4},{"partnumber":"p2","genuineFlag":"x","installedFlag":"x","installationDate":"2017-02-25","quantity":3}]}

The issue is that the REST service consumer doesn't accept the format with the additionnal field "parts".

Can Someone help me, please?

Kind Regards

Eric Koralewski

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

Hi Eric,

You need to follow the below steps:

1. Set parts as ArrayType under the XML/JSON conversion Rules.

2. Use "setIgnoredElements" for parts under the REST module tab.

0 Kudos

Hi,

can you please add root instead or parts and try? whether it get escaped in JSON conversion.

0 Kudos

Hi Eric,

I meet the same issue now. Did you find any solution to this issue yet?