Skip to Content
0
Oct 14, 2020 at 01:10 AM

Rest sync receiver - Array JSON result with no main element

194 Views Last edit Oct 14, 2020 at 01:11 AM 2 rev

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