Hi,
I'm building a simple desktop flow to connect to an non-public, on prem API - the first stage is authentication. I'm using the Web Service Invoke method.
The Request body of this is JSON, in the format:
{"username":"USERNAME","password":"PASSWORD"}
When I run this, I get an error message back from the API, saying:
{"url":"/MagicInfo/auth","errorCode":"500000","errorMessage":"JSON parse error: Unexpected character ('%' (code 37)): expected a valid value (number, String, array, object, 'true', 'false' or 'null'); nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('%' (code 37)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: java.io.PushbackInputStream@23e0bd3; line: 1, column: 2]","errorDetails":null}
Running fiddler, to inspect the HTTP request, I see that the actual request body is being converted to:
%7b%22username%22%3a%22USERNAME%22%2c%22password%22%3a%22PASSWORD%22%7d
It seems like the ASCII codes for the characters are being passed - and changing the encoding in the advanced settings (e.g. to utf-8) doesn't change this.
Does anybody have any ideas on why this is happening, or any solutions?
Thanks,
Josh
Solved! Go to Solution.
There is an "Encode request body" which you can disable:
Did you specify the content type header ?
Content-Type: application/json; charset=UTF-8
I have similar issue, content of "Request Body" seems not to be transmitted at all.
I used Postman Echo Service, its ends back your request, Body is missing, non existent, null.
Note: I tried adding "charset-UTF-8" as @fraenK suggested.
I tried checking the request with Fiddler, but it is not picking it
As you can see in the screenshots
1. The request, simple json object in the body
2. Web Service Response (Body should be inside "args" but its empty.
3. Same response when sent with Postman (Body is inside "args")
If you want to send JSON data to a server then you'll need to use e.g. POST or PUT, not GET
I know that, but POST does not work, that's why I had to test with postman echo test, that confirmed my suspicion, Postman echo service works with GET, as you can see.
If you know that GET uses URL parameters, then why do you expect sending a JSON body to work?
POST works fine with https://hookbin.com/NOzq3PxgoBHWZZpRgGQ2:
Web.InvokeWebService Url: $'''https://hookb.in/NOzq3PxgoBHWZZpRgGQ2''' Method: Web.Method.Post Accept: $'''application/json''' ContentType: $'''application/json''' RequestBody: $'''{\"test\":\"test\"}''' ConnectionTimeout: 30 FollowRedirection: True ClearCookies: False FailOnErrorStatus: False EncodeRequestBody: False UserAgent: $'''Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20100312 Firefox/3.6''' Encoding: Web.Encoding.AutoDetect AcceptUntrustedCertificates: False ResponseHeaders=> WebServiceResponseHeaders Response=> WebServiceResponse StatusCode=> StatusCode
So this is what I am getting
https://hookbin.com/NOzq3PxgoBHWZZpRgGQ2/9RzpKBjpE
I see your body was also parsed like this once, what did you change?
There is an "Encode request body" which you can disable:
This fixed the issue.
Thanks!
Disabling "Encode request body" worked for me too.
Cheers All 🙂
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.