Introduction
Microsoft has provided tons of connectors in FLOW to interact with hundreds of applications out there. Still, at some point, you might need to build your own connector or build REST APIs which are communicating to your other applications. You call your REST APIs from FLOW easily with HTTP action. This is a powerful action which you can use to pull data, push data, update data. In this article, we are going to look at how we can send JSON data as a body to HTTP action correctly.
Problem
When it’s data then, of course, it must be generated dynamically depending upon your source request item. In FLOW you can generate JSON data by contenting the values and storing them in a string variable. But when you pass this string variable to HTTP action it fails. It treats data as a plain text body parameter, not JSON. You will get an UnsupportedMediaType error as shown below.
The request entity's media type 'text/plain' is not supported for this resource.

Solution
Let’s see how to overcome the above error. We need to parse the string into JSON object and then send it to HTTP action.
Let’s see how to do it step by step.
Login to Microsoft FLOW web service and Edit your FLOW >> Add a variable in which you can store the concatenated string JSON data >> Set the variable with your dynamic content in JSON format.
When I say JSON format, I mean a string like {"Parameter1": "Value1", "Parameter2": "Value2"}

Add Parse JSON action after it >> Set the Content of this action to your variable, i.e., strJsonData in our case. Now, we need to tell this action how the schema of our JSON data is. So, click on "Use sample payload to generate schema" – this will help to generate the schema automatically instead of typing it manually and making errors.







Sumit AroraPosted Jul 1, 2021, 12:11 PM
Hi,I just want to pass a parameter "/sampledomain1987.sharepoint.com/sites/POCTeamSite" .How can I parse this into JSON
Shyam SPosted Jul 16, 2020, 11:38 PM
Excellent. It worked for me thanks.