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
Register for a Free Workshop.png

Register for a Free Workshop

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

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (1,844)