cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Advocate I
Advocate I

How to Extract an Array from a JSON Object to Use in a Apply To Each

I have a Swagger Defined REST Web Service that returns something in the format of the following:

 

{
    "Id": "86790819-21b1-4881-9af2-86297f586021",
    "Status": "OK",
    "ProviderName": "MyApp",
    "DateTimeUTC": "/Date(1508339098344)/",
    "Invoices": [
        {
            "Type": "ACCPAY",
            "InvoiceID": "20ff01b8-c2d8-49bb-8abf-a9486c9ea665",
            "InvoiceNumber": "RPT644-1",
            "Reference": "",
        },
        {
            "Type": "ACCPAY",
            "InvoiceID": "20aaa1b8-c2a8-49ab-8abf-a9a86caeaaa6a",
            "InvoiceNumber": "RPT644-2",
            "Reference": "",
        }
    ]
}

I want to cycle through all of the Invoices and grab the InvoiceId to then use in a later flow call, but I can't figure out the proper way to reference the properties of a JSON.

 

Since this structure is all defined in Swagger, I thought it would be as easy as doing an Apply To Each on the Invoices; but that is not identified as a parameter since its an object that has a property that has an array.

 

Based on my searches, it sounds like I should be able to use Compose somehow, but I'm not sure how to reference the property.

 

e.g. In concept, I feel like I should be able to put the following as the source of a Apply To Each:

 

json(body('getInvoices')).Invoices
 
But that gets a syntax error. There has to be something similar, but I can't seem to find a place where all of this is documented and even the old threads on here seem to show an earlier version of Microsoft Flow with stuff like Value{} which I don't see anywhere.

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Advocate I
Advocate I

As soon as I posted this, I found more actions I hadn't seen before.

 

1) Search for "Compose" within Actions.

2) Choose "Parse JSON"

    - I gave an example payload for parsing.

3) Choose Apply To Each and use the Array as Input

 

 

Wallah, I'm good to go.

View solution in original post

3 REPLIES 3
Advocate I
Advocate I

As soon as I posted this, I found more actions I hadn't seen before.

 

1) Search for "Compose" within Actions.

2) Choose "Parse JSON"

    - I gave an example payload for parsing.

3) Choose Apply To Each and use the Array as Input

 

 

Wallah, I'm good to go.

View solution in original post

Hi @DougL  for point 3 3) Choose Apply To Each and use the Array as Input, what is the array you compose?

I have the same problem.

Kind regard

Here's something new for you... the expression is Voilà 😀

https://0.tqn.com/z/g/french/library/media/wavs/voila.wav 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (11,523)