cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
DougL
Level: Powered On

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
DougL
Level: Powered On

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

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

2 REPLIES 2
DougL
Level: Powered On

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

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

IronFelix
Level: Powered On

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

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

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 314 members 6,042 guests
Please welcome our newest community members: