cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JesseW
Frequent Visitor

Issues with Parse JSON function

Hi guys,

 

I am running into issues parsing the following JSON response with a dynamic array id, which in the below example is "697676":

 

{
"superAdjustments": {
"697676": [
{
"notes": null,
"amount": 405.46,
"contributionType": "Employer Contribution",
"id": 321838,
"externalId": null,
"locationId": "174855",
"locationName": "Mkt-023",
"employeeId": "697676",
"employeeName": "Christopher WOOD",
"employeeExternalId": "a3V28000000wnh2EAA"
}
]
},
"payRunId": 3346135
}
 
When I set the Parse JSON schema it hard codes the array id, how can this be set to dynamically update?
 
 
Below is the top of the JSON schema where the array is defined:
2019-06-09_10-05-58.png
 
Below is an example of flow failing due to the response array id, not matching the static array value set within the schema:
 
2019-06-09_10-03-59.png
 
Any guidance would be greatly appreciated, thanks.
1 ACCEPTED SOLUTION

Accepted Solutions
yashag2255
Dual Super User II
Dual Super User II

Hi @JesseW 

 

The issue you are seeing is because of the key mentioned in JSON payload and the variable you used in Apply to Each, has the same ID as your payload rather than having the output ID. This can be resolved if you pass correct ID in the Apply to Each input.
 
Please follow the below steps:
 
1) Initialize a variable to store the dynamic ID after the Parse JSON action. 
    Expression: 
split(string(body('Parse_JSON')?['superAdjustments']),'"')[1]
    This gets the dynamic ID.
 
2) Input for the Apply to Each Action with the below formula:
body('Parse_JSON')?['superAdjustments']?[variables('DynamicId')]MicrosoftTeams-image (101).png

Hope this helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

2 REPLIES 2
yashag2255
Dual Super User II
Dual Super User II

Hi @JesseW 

 

The issue you are seeing is because of the key mentioned in JSON payload and the variable you used in Apply to Each, has the same ID as your payload rather than having the output ID. This can be resolved if you pass correct ID in the Apply to Each input.
 
Please follow the below steps:
 
1) Initialize a variable to store the dynamic ID after the Parse JSON action. 
    Expression: 
split(string(body('Parse_JSON')?['superAdjustments']),'"')[1]
    This gets the dynamic ID.
 
2) Input for the Apply to Each Action with the below formula:
body('Parse_JSON')?['superAdjustments']?[variables('DynamicId')]MicrosoftTeams-image (101).png

Hope this helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Brilliant thank you so much @yashag2255. This is now working as expected!

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (89,795)