Something that is used a lot in Microsoft Flow is the HTTP request. Whether you are calling a site’s REST endpoint or an Azure function, or in the case of today a SharePoint REST endpoint you need to be able to do something with the data returned. The steps to do that are very simple and only require a free tool called Fiddler. You can download Fiddler here (please note: I have nothing to do with Telerik, it’s just a nice tool I use often). Go ahead and download the tool and we’ll move forward with the steps parsing JSON in Microsoft Flow
Prepare the Flow
Let’s start off with a list. I want to use a REST call to access the list (I am aware there is an actual action for this, but I want to show how easy parsing the data is).
Next I want to build a quick flow that gets the data via the following REST call: https://<SiteURL>/sites/PowerApplications/_api/web/lists/getbytitle(‘TestData’)/items(1). This call simply returns the item with a list ID of 1.
I am just going to build a simple flow that starts when an item is added (remember the purpose of this post is to handle JSON so I am making it as simple as possible). Next I add an HTTP request to SharePoint with the above REST call:
Parsing JSON in Microsoft Flow
Now I need to add a new action called Parse JSON. There are two items within the action.
- Content – determines where the JSON is coming from
- Schema – Translates the JSON into properties that can be used within the flow.
We set the content to the HTTP Call and the schema? Well that’s why we are here. Next we need to determine what the schema is going to look like. To do this, open up Fiddler and run the REST call you wish to run in your flow.
On the left hand side of the window are the responses captured by fiddler. You are looking for the 200 that occurred immediately after you executed your REST call. Double click on it to open the response in your window.
Once you have confirmed the data is what you are looking for, right click on the 200 response and select Save –> Response –> Response Body
Save the response to a file and then open the file in the editor of your choice. Copy the contents of the file and go back to your flow. Next we are going to initiate the schema builder that Flow has built in. To do this click on the link in the Parse JSON action labeled: “Use sample payload to generate schema“. This opens a new window that you will paste the copied JSON response into. Special note: the builder is expecting a single line and your editor may break that up into multiple lines so be prepared to fix it.
At this point your flow should look something like this:
Now when you add a component that needs data from that REST call it is available as properties within the flow:
Thanks for reading!!