on 03-14-2017 11:14 AM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
can you please add root instead or parts and try? whether it get escaped in JSON conversion.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Eric,
I meet the same issue now. Did you find any solution to this issue yet?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.