Iterating a JSON array in LogicApps

Viewed 602

I'm using a LogicApp triggered by an HTTP call. The call posts a JSON message which is a single row array. I simply want to extract the single JSON object out of the array so that I can parse it but have spent several hours googling and trying various options to no avail. Here's an example of the array:

[{ "id": "866ef906-5bd8-44d8-af34-0c6906d2dfd7", "subject": "Engagement-866ef906-5bd8-44d8-af34-0c6906d2dfd7", "data": { "$meta": { "traceparent": "00-dccfde4923181d4196f870385d99cb84-52b8333f100b844c-00" }, "timestamp": "2021-10-19T17:01:06.334Z", "correlationId": "866ef906-5bd8-44d8-af34-0c6906d2dfd7", "fileName": "show.xlsx" }, "eventType": "File.Uploaded", "eventTime": "2021-10-19T17:01:07.111Z", "metadataVersion": "1", "dataVersion": "1" }]

Examples of what hasn't worked: Parse JSON on the array, error: InvalidTemplate when specifiying an array as the schema For each directly against the http output, error: No dependent actions succeeded.

Any suggestions would be gratefully received.

2 Answers

You have to paste the example that you have provided to 'Use sample payload to generate schema' in the Parse JSON Connector and then you will be able to retrieve each individual object from the sample payload.

enter image description here


enter image description here

You can extract a single JSON object from your array by using its index in square brackets. E.g., in the example below you'd need to use triggerBody()?[0] instead of triggerBody(). 0 is an index of the first element in the array, 1 - of the second, and so on.

enter image description here

Result:

enter image description here

Related