cancel
Showing results for 
Search instead for 
Did you mean: 

Rest sync receiver - Array JSON result with no main element

JaySchwendemann
Active Contributor
0 Kudos

Dear all,

Situation

I have a ERP (Proxy) --> PI --> 3rd Party (REST) synchronous scenario. I'm using GET to receive data. I'm on PO 7.5 SP13

The 3rd party service either provides a single record or multiple records as JSON array as a response.

Single:

{
    "guid": "1234",
    "subject": "My subject",
    "existEmlAlready": true
}

Multi:

[
    {
        "guid": "1234",
        "subject": "My subject",
        "existEmlAlready": true
    },
    {
        "guid": "4321",
        "subject": "My other subject",
        "existEmlAlready": true
    }
]

What I want to achieve

I want to ideally process both responses with a single operation with a single response message type

Single

<messageType>
	<record>
		<guid>1234</guid>
		<subject>My subject</subject>
		<existEmlAlready>true</existEmlAlready>
	</record>
</messageType>

Multi

<messageType>
	<record>
		<guid>1234</guid>
		<subject>My subject</subject>
		<existEmlAlready>true</existEmlAlready>
	</record>
	<record>
		<guid>4321</guid>
		<subject>My other subject</subject>
		<existEmlAlready>true</existEmlAlready>
	</record>
</messageType>

What I tried / where I fail

  • I specified wrapper element as "record", however that failed in response message mapping as messageType could not be created
  • I briefly fiddled with Custom XML/JSON conversion Rules but I have a guts feeling that this is not relevant for my situation as it should be dealing with XML to JSON conversion and will not help me to convert a single { ... } JSON into an array [ { ... }, { ... } ] like json.

My Questions

  1. Am I right in the assumption that Custom XML/JSON Conversion Rules are not relevant for my problem?
  2. Is there a solution to my problem without asking the 3rd party to change their payload?
  3. To put 2. another way: If the 3rd party would introduce a "main element" like "record": [ { ... }, { ...} ] respective "record" : { ... } --> Will this solve my issue because I can then specify "messageType" as wrapper element?

Many thanks and kind regards

Jens

dileepkrc307
Participant
0 Kudos

Dear Jens,

I got requirement like you..here is ECC to PI to third party.Third party wants json request structure as Below so how can I achive this requirement could you please help on this requirement

[{ "employee_id":"44556", "establishment_head_mobile_number":"9999999999" }, { "employee_id":"33423", "establishment_head_mobile_number":"9999999999" }]

Thanks and Regards,

Dileep

Accepted Solutions (0)

Answers (3)

Answers (3)

Ryan-Crosby
Active Contributor

Hi Jens,

I did a prototype of something similar to this several months ago although it might be slightly different. I'm not sure if it had the anonymized array element to it but this is something that you can try that may work. I set my REST sender channel to convert to XML but did not do anything with the wrapper element. Inside my operation determination I used a variable in the HTTP path to derive the message type that I wanted to use and all it has is a single data type of type string (although in your case it might need to be 0...unbounded instead). Here are some screenshots to give you an idea:

Maybe this will help give an approach to solve it.

Regards,

Ryan Crosby

JaySchwendemann
Active Contributor
0 Kudos

Thanks a heap, Ryan.

so bottom line of your solution would be using different expressions (you only have one in the screenshots) to map to different operations like so:

  • ABCReader --> ABCReaderQCRequest
  • XYZReader --> XYZReaderQCRequest

However, I feel I would not be able to adapt this fully, I'm afraid. I briefly lay out where I think I might fail:

  • I have a receiver sync REST channel and dealing with the response. While that is roughly the same (concept wise) as dealing with a sender request, you don't have the same options
  • I don't have the Operation Determination for example. I have Operation Rules where I map the outgoing (to the 3rd party) operation / request message type to an variable and give that a value, here "GetZip"
  • I have Response Determination tab, where, If I understood the concept correctly, I could map an XML response from the 3rd party to an operation on PI like so

  • However, I don't have an 3rd party service, that sends back an XML node, it sends an unnamed array of JSON records or a single record (see original post)

  • Even if I could persuade the 3rd party to send a named array / object like so...
    aaa

    "record": [{
            "guid": "1234",
            "subject": "My subject",
            "existEmlAlready": true
        }, {
            "guid": "4321",
            "subject": "My other subject",
            "existEmlAlready": true
        }
    ]
    
    ... would PI then magically convert that to an XML and if so, would the root XML response node than be "record" and what would the namespace be.

Lot's of questions I dont excpect you to have an answer, of course. But I tried to give as much detail as necessary, so you and others might get a grisp of the roadblocks in this scenario 😄

Anyways, a big Thanks and cheers

Jens

Ryan-Crosby
Active Contributor
0 Kudos

Hi Jens,

Yes, your scenario is clearly different being synchronous but it may still be worth a short in setting a data type structure for thirdPartyXMLRootNode like I have suggested and have the system doing the XML conversion. For the sake of keeping it simple set the type to single string and see what happens because that may give you clues about whether 0...unbounded would work. I just don't have a scenario with an anonymized array that I can test out my system with or I would have tried it to confirm.

Regards,

Ryan Crosby

dileepkrc307
Participant
0 Kudos

Dear Jens,

I got requirement like you..here is ECC to PI to third party.Third party wants json request structure as Below so how can I achive this requirement could you please help on this requirement

[{ "employee_id":"44556", "establishment_head_mobile_number":"9999999999" }, { "employee_id":"33423", "establishment_head_mobile_number":"9999999999" }]

I am able to send request in below format but third party wants above format

{ "root":[{ "employee_id":"44556", "establishment_head_mobile_number":"9999999999" }, { "employee_id":"33423", "establishment_head_mobile_number":"9999999999" } ] }

Thanks and Regards,

DILEEP

vijayanandpaul_puvvula3
Active Participant
0 Kudos

In the Response Type tab, make sure you provide the details mentioned above. make sure your response message type for the SI is 0...Unbounded.

Regards,

Paul.

JaySchwendemann
Active Contributor
0 Kudos

Hi Paul,

could you elaborate on your answer, please? Which detail do you talk about? Will I go for custom JSON / XML conversion rule or other means? Which "response type tab" do you mean? Is it "Response Determination"?

Thx & Cheers