We are using the Invoke Web Service action to retrieve some json, but when we go to loop through the list of items in the json, it doesn't work. Currently, we are doing this:
1) Using the Convert JSON to custom object to turn out json string into a workable object.
2) Using the Add item to list action to add the custom object from step #1 to a new list
3) Using a For each loop to parse the new list, but the conversion to list (step #2) seems to fail to break up the json into separate items, but instead the list just has one massive item (all of the json).
Any idea on how to loop through json with Power Automate Desktop?
Solved! Go to Solution.
We resolved this issue by referencing the collection in the loop. It seems that we were at first, but figure out needed syntax.
We resolved this issue by referencing the collection in the loop. It seems that we were at first, but figure out needed syntax.
can u pls give examples? I need to see the formatting. thx in adv
where have you resolved I have the same issue
We are using the Invoke Web Service action to retrieve some json, but when we go to loop through the list of items in the json, it doesn't work. Currently, we are doing this:
1) Using the Convert JSON to custom object to turn out json string into a workable object.
2) Using the Add item to list action to add the custom object from step #1 to a new list
3) Using a For each loop to parse the new list, but the conversion to list (step #2) seems to fail to break up the json into separate items, but instead the list just has one massive item (all of the json).
Any idea on how to loop through json with Power Automate Desktop?
Hello,
stuck at the same step, currently evaluating Microsoft's LowCode offering in my job. Testing a few standard usecases and support channels.
Task: Retrieve data from webservice and persist in csv.
Attempted solution:
Error: Variable 'JsonAsCustomObject' must be a list, datatable or datarow.
Is there actually any useful implementation in Power Automate Desktop for consuming/processing a custom object? The screenshots in Power Automate Desktop Extract null from JsonAsCus... - Power Platform Community (microsoft.com) seem to suggest it should work!?
Here is what we did to make this work:
1) Invoke Web Service
2) Convert JSON to custom object
3) For each on the custom object (be sure to reference the collection inside the object if there is this is a separate part).
After many hours of trial and error and reading everything I could find on the matter, I believe I got what is going on.
If the json collection you are trying to iterate is not an index based array, you cannot iterate using Power Automate Desktop loop functions. You will get an error like this: "it's only possible to iterate a list, datatable or datarow."
On the other hand, if the json collection is index based, you will be able to use loops (ex. "foreach") to iterate each entry.
Example of an index based json collection:
{
"vulnerabilities":[
{
"cvss":"9.8",
"code":"234234",
"title":"scary vuln"
},
{
"cvss":"7.8",
"code":"222222",
"title":"somewhat scary vuln"
}
]
}
Working sample in Power Automate Desktop
For a json file of the following structure :
I did the following :
I have read FileContents as a SingleTextValue
In the RPA flow above, please do not add the part where I am creating a new list. It's not needed
In the display message I printed the json object with property: PONumber as follows :
it printed the PONumber as follows :