I have a json file that looks like this:
{
"first key": "some url",
"second key": "some other url",
"third key": "yet another url",
...
}
I want to make a azure logic app that sends an http request (with the same body) to each of those urls. What i need to do is to iterate over urls, but i have no idea how to do so since it is not an array. For now all i have is getting the json file from blob storage and parsing it inside logic app to get shown output.
One more thing worth mentioning is that this json may have more or less keys, this number varies. Sometimes it will consist of 5 urls, sometimes 2. Also names: "first key", "second key", "third key" are not important here and will not be accessed anywhere in logic app if that helps. All i can assume is that those will be unique strings.
Tried all options of "for each" block, but all i have achieved is accessing specific url by providing specific key.
CodePudding user response:
If you can hold out, there is an operation coming in the Advanced Data Operations
connector which is due to drop in preview sometime in Feb, 2023.
The above operation will produce the following result ...
[
{
"propertyName": "first key",
"propertyType": "String",
"propertyValue": "some url"
},
{
"propertyName": "second key",
"propertyType": "String",
"propertyValue": "some other url"
},
{
"propertyName": "third key",
"propertyType": "String",
"propertyValue": "yet another url"
}
]
This will allow you to iterate over the object and pull each value (along with the property name if required) as you desire.
If you can't hold out, the operation is available via the HTTP connector, you just need to read the documentation on how to structure the JSON for the call.
https://www.statesolutions.com.au/json-properties-to-name-value-pair-array/
CodePudding user response:
Issue reproduced from my end follow these steps.
Add compose action and form array with http body. Based on http request body you need to add urls dynamically. I have done as shown below,
Created logic app as shown below,
In http request sending body as shown below,
{
“link1”: “some url”,
“link2”: “some other url”,
“link3”: "yet another url
}
3. In compose action, forming array with http body as shown below,
- Next taken for each loop and passing outputs of compose action as input,
In this way it will iterate over each url of the Http body request.
logic App ran successfully as shown below.