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

Loop a List Record value and add it into a HTTP step JSON body

Hi all

 

I'm having some trouble building a specific flow. I've got a list record CDS step built in Flow which will provide me with a list of products in Dynamics. I've got a specific field in product called fieldName which provides a list of name values which I'll use in a HTTP step JSON to push data via a REST API.

 

So what I first did was create a blank Initialize string variable which will later store a concatenated object values for later use.

 

image.pngCreate blank variable

 

Later in the step I get product using the ID in a previous List record step.

image.png

 

I then use the append to string to append a concatenated value of the products along with a few delimiters that mimic a JSON object.

 

concat('"',outputs('Get_Product')?['body/description'],'":true,')

 

I then in a later step created a HTTP PUT request to a REST API endpoint and added in the variable into the JSON body but it's giving me a error and asking me to enter a valid JSON object.

 

image.png

 

I've tested the output of the concatenated value and they come out as mimicking a JSON object but for some reason I can't add it to a HTTP request. Below is what the variable output looks like:

 

"Product1":true,"Product2":true,"Product3":true,"Product4":true,"Product5":true,"Product6":true,"Product7":true,"Product8":true,

 

3 REPLIES 3
Community Support Team
Community Support Team

Re: Loop a List Record value and add it into a HTTP step JSON body

 

Hi @Mick282 ,

 

You seem to need to remove the last comma from the value of the variable.

 

Manually add a comma after the variable when configuring the Body.

 

Best Regards,

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

Re: Loop a List Record value and add it into a HTTP step JSON body

I thought about the comma but that's why I placed the dynamic content for the products at the top. Then I can loop them all with the commas and then I left EmailAddress without a comma.

Community Support Team
Community Support Team

Re: Loop a List Record value and add it into a HTTP step JSON body

 

Hi @Mick282 ,

 

Your thinking is correct, but this configuration does not seem to pass the verification of the body, because each property needs to be separated by a comma, and the variable is considered a property, but there is no comma after it, so this problem occurs.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,676)