cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
eauerbach
Helper III
Helper III

Best Way to Handle Variable JSON Formatting When Parsing

I've been working on a flow that will retrieve FedEx API data. The flow is pretty straightforward, taking a tracking number from a canvas app, calling the API, and then returning the formatted JSON to the app for display. I'm having issues as the FedEx return is not constant: some of the nodes vary between an array or an object. I've tried setting up failover by configuring Run After with different JSON samples that I've received, but the API continues to come up with new structures (current iteration allows for 3 different JSON results). 

eauerbach_0-1635277383377.png

 

What's the best way to handle an API result that can provide different structures for the same call?

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @eauerbach 

 

Look at the schema and manually delete those nodes where it says mandatory from the JSON or set to accept null for those properties which are complaining about.

 

"Age": {
"type": ["number","null"]
},
"Name": {
"type": ["string","null"]
},

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

View solution in original post

4 REPLIES 4
abm
Super User
Super User

Hi @eauerbach 

 

This is not a flow issue. The schema validation for that JSON you have used can only validate based on you have provided. I would recommend to look the API documentation and see the full sample dataset and generate the schema. Also remove the mandatory schema validations once the object is generated so that it could handle all the scenarios.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Thanks @abm . How do I disable mandatory validation? 

Hi @eauerbach 

 

Look at the schema and manually delete those nodes where it says mandatory from the JSON or set to accept null for those properties which are complaining about.

 

"Age": {
"type": ["number","null"]
},
"Name": {
"type": ["string","null"]
},

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
eauerbach
Helper III
Helper III

Thank you @abm ! Works great now.

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,454)