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

Parse JSON output

I have JSON objects return from HTTP request. Sample object:

{

"meta": {

"somedata": "value"

}

"group": [

{

            "name": "myname",
            "url": "https://somesortofurl.com/914765"

},

{

            "name": "myname2",
            "url": "https://somesortofurl.com/9147644"

}

]

}

 

I want to create a 1) for each loop to extract only url from all the objects  2) and also the numeric values from the url so left(value,6). I will use the numeric value to create another http request. 

 

I tried For Each also tried to do it by compose using something like trigger()['group']['url'] but can't get this to work.  Any guidance would be much appreciated

 

4 REPLIES 4
Community Support Team
Community Support Team

Re: Parse JSON output

Hi @smerchant,

 

Have you tried the parse JSON action?

Parse JSON messages

 

Besides, you should be able to reference the trigger output through:

TriggerBody()?['group']?['url']

Regards,

Michael

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
smerchant
Level: Powered On

Re: Parse JSON output

Thanks for a response @v-micsh-msft.  I indeed have used JSON Parse.  How should I add TriggerBody in the expression is it like TriggreBody('ParseOutput')?['server_list']?['url']?

 

 

Here are some screenshots

 

 

Output received from the JSON Parse

 Screenshot_8.png

 

Flow Screenshot

 

 

 flow.png

 

Error:

The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('HTTP')' is of type 'String'. The result must be a valid array.

 

smerchant
Level: Powered On

Re: Parse JSON output

@v-micsh-msft please could you help?  Thanks,

NazIM
Level: Powered On

Re: Parse JSON output

Try using 

Body('Parse_JSON')?['Group']?['URL']

Or

Body('Parse_JSON')?['Group']?['1']?['URL']

Or

Body('Parse_JSON')?['Group']?['1']?['URL']

The first option works for me, but I dont have duplicate entries under the header (i.e.: you have multiple entries for URL). So I guess you will have to refer to them by index. 

 

Do let us know what works. 

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: 328 members 5,886 guests
Please welcome our newest community members: