Skip to Content
0

SAP PI Rest Sender Synchronous Mutiple occurences in array

Feb 05 at 07:48 PM

32

avatar image
Former Member

Hi All,

Synchronous scenario Rest---->PI----->SAP

Issue: Response JSON format is different than what expected, if a sub node - root tag is appended it looks good but Rest API service does not allow any root tags and with out root tags the complete format is converted as shown below, any suggestions appreciated

Primary Root node = MT_Test

Sub node = SAP

When I strip MT_Test and XMl sub node under MT_Test with 0:unbound occurrences it works fine but no root tags are allowed in REST API


Expected JSON response

[
{
"Name": "SAPPI",
"No": "1111",
"CompanyDetails": [
{
"id": "1112",
"name": "SAPPITEST_1",
"MaterialNo": "1112"
},
{
"id": "1113",
"name": "SAPPITEST_2",
"MaterialNo": "1113"
}
]
},
{
"brandName": "SAPHCI",
"partNo": "2222",
"CompanyDetails": [
{
"id": "2223",
"name": "SAPPHCITEST_1",
"MaterialNo": "2223"
},
{
"id": "2224",
"name": "SAPPHCITEST_2",
"MaterialNo": "2224"
}
]
}
]


Received JSON Response after strip Root tag (MT_Test), If you observer Name and No values are pooled together and all Company Details together in one array which is not expected



[{
"Name": [
"SAPPI",
"SAPHCI"
],
"No": [
"1111",
"2222"
],
"CompanyDetails": [
{
"id": "1112",
"name": "SAPPITEST_1",
"MaterialNo": "1112"
},
{
"id": "1113",
"name": "SAPPITEST_2",
"MaterialNo": "1113"
}
]
},
{
"brandName": "SAPHCI",
"partNo": "2222",
"CompanyDetails": [
{
"id": "2223",
"name": "SAPPHCITEST_1",
"MaterialNo": "2223"
},
{
"id": "2224",
"name": "SAPPHCITEST_2",
"MaterialNo": "2224"
}
]
}
]



When add sub node value SAP as root tag after striping root node (MT_Test) it looks good but api service does not support root tags, used replace string bean to remove root tag and message converts to received Json response shown above

[
{
"SAP": [
{
"Name": "SAPPI",
"No": "1111",
"CompanyDetails": [
{
"id": "1112",
"name": "SAPPITEST_1",
"MaterialNo": "1112"
}
{
"id": "1112",
"name": "SAPPITEST_1",
"MaterialNo": "1112"
}

]
},
{
"Name": "SAPHCI",
"No": "2222",
"CompanyDetails": [
{
"id": "1112",
"name": "SAPPITEST_1",
"MaterialNo": "1112"
}
{
"id": "1112",
"name": "SAPPITEST_1",
"MaterialNo": "1112"

}
]
}
]
}
]

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

G SHIVA Feb 28 at 07:20 AM
0

Hi Gaurav ,

Change the max occurrence of node to "unbound and use custom XML/JSON conversion rule for node as an array .

This should work for you.

Best ,Shiva

Share
10 |10000 characters needed characters left characters exceeded