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 Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Users online (1,026)