How to fix "Unsupported Media Type" error for any Post Orchestrator API request starting from Orchestrator 2020.10
Issue description:
UiPath swagger API specification describes that POST requests made to Orchestrator must have the request parameters included in a JSON in the request body. However, due to historical reasons, the web framework used before 20.10 also allowed making POST requests to our APIs by specifying request parameters as form parameters, even without specifying the proper Content-Type of application/x-www-form-urlencoded. This is not supported anymore.
If this is not followed, you may run into an error that may look like the following:
Resolution:
Hence, the request parameters should be passed in JSON format in the “Body” field of the ‘HTTP Request’ activity. Also, the “BodyFormat” should be set to “Application/json”.
Any of the below approaches can be followed to pass the body as JSON.
Approach 1:
Pass the complete JSON body in a single line string. Make sure to add extra " before " as escaping character.
Example of request body:
"{ ““tenancyName”” : ““default””, ““usernameOrEmailAddress”” : ““admin””, ““password”” : ““UiPath@123"”}”
Approach 2:
Write the complete body in a text file. Read it using the “Read Text File” activity and pass the output variable in the “Body” field of the ‘HTTP Request’ activity.