Skip to Content

Array and object issue in JSON, REST

HI all,

I have a synchronous scenario. REST --- PI --- ECC --- PI --- REST

In the response receiver payload, I have an item node. I have given it as 0..unbounded since it can have either multiple items or single item. REST Communication channel is converting to JSON from xml. Everything is working fine. However the receiver application complains that they are getting the items node as object and array.

If items have multiple items under that node then, JSON structure is like this:

"Item": [

{

"ItemNumber" : "00001",

"ItemDescription" : "xyz"

"Quantity" : "0"

}

{

"ItemNumber" : "00002"

"ItemDescription" : "abc"

"Quantity" : "0"

}

]

Now if item has only single item under that node, the JSON structure is like this:

"Item" : {

"ItemNumber" ; "00004",

"ItemDescription" ; "def",

"Quantity" : "0"

}

They receiver REST application wants Item to come as an array even if there is one single item. How is this possible with PI?

Regards

Harish Babu

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jan 28, 2016 at 02:42 AM

    Harish

    This can be achieved using enhanced JSON conversion as described in Vadim's blog below. You need to configure the conversion table and set that specific node to an array type.

    REST Adapter in PI/PO: Enhanced XML/JSON Conversion

    Make sure you are on the right SP/Patch which mentioned in SAP Note 2175218.

    Rgds

    Eng Swee

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Stefan,

      Yes, you have to import newer adapter metadata (provided within XI Content for software component SAP_BASIS) in order to be able to see new features in user interface when configuring communication channels.

      You may check SAP Note 2276231 for details, or you can also check some SCN forum threads that discuss similar problems - for example, .

      In SAP Service Marketplace, download XI Content that corresponds to release and Support Package level of your PI system (ignoring Patch Level of a specific software component)

      Regards,

      Vadim

  • Posted on Jan 27, 2016 at 11:11 AM

    Hi Hareish,

    Check alex reply in the below blog.

    PI REST Adapter - Consuming synchronous RESTful service

    Hi Nida,

    will be supported with next SP shipment 7.31 SP17 / 7.4 SP13, planned to be shipped in November

    Alex

    Regards,

    Praveen.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.