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

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

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!

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

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,721)