cancel
Showing results for 
Search instead for 
Did you mean: 

REST ADAPTER: Problem with XML/JSON custom rules conversion array type

former_member617998
Discoverer
0 Kudos

xmlcustomrules.png

Hello all,

We are configuring a PROXY to REST Synchronous scenario in which we have to do XML to JSON payload conversions.

The expected payload is:

"AsnMaterialDetails":[{

"Item":313006063,
"Quantity":10
}]

But the REST adapter is providing the payload as:

"AsnMaterialDetails":{
"Item":313006063,
"Quantity":10
}

I have properly configured the XML/JSON custom rules, where we define the node as an array but it was still not working.

https://blogs.sap.com/2016/01/13/rest-adapter-in-sap-pipo-enhanced-xmljson-conversion/

I followed through this blog where the same issue was mentioned. but it was not yet resolved for me

Any help on the issue would be helpful.

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member607993
Contributor
0 Kudos

Hi Aditya,

If target structure looks like:

</MessageType>

</AsnMaterialDetails>

<Item>313006063</Item>

<Quantity>10</Quantity>

</AsnMaterialDetails>

</MessageType>

Then in the Receiver REST Communication channel, under Data format > Customer XML/Json Conversion Rules you need to provide below response related details like prefix(ns0), namespace, response message type and Array Type set it to 'true'.

This indeed constructs the Response payload in a Array type object [{...}] and delivers appropriately.

Thanks and Regards - Rajesh PS

manoj_khavatkopp
Active Contributor
0 Kudos

Leave the "XML Namespace" and "prefix" blank . Just Define the element name and set array type as true for that , it should work.

former_member617998
Discoverer

Hello Manoj!
I tried that but it was still not working.

former_member190293
Active Contributor
0 Kudos

Hi Aditya!

And what does your source XML payload look like?

Regards, Evgeniy.

former_member617998
Discoverer
0 Kudos

Hello Evgeniy!

Thanks for your response. My xml payload which needs to be converted into json is

<AsnMaterialDetails>

<Item/>

<Quantity/>

</AsnMaterialDetails>

I need to define the node "AsnMaterialDetails" as an array type. when the occurrence of the node is 1, then it is not getting considered as an array and thus the third brackets "[]" are missing.

former_member190293
Active Contributor
0 Kudos

Hi Aditya!

I don't see any xml namespace declarations in the example you've provided.

Also attach full screenshot of your XML-JSON conversion settings.

Regards, Evgeniy.