cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

PAD - Web Servcie Invoke

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
9 REPLIES 9
fraenK
Super User
Super User

Did you specify the content type header ?

 Content-Type: application/json; charset=UTF-8
Lipsitz
Advocate I
Advocate I

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")

 

2021-04-13 14_01_19-Invoke web service.png2021-04-13 14_01_00-Test API _ Power Automate Desktop.png2021-04-13 14_00_00-Postman.png

If you want to send JSON data to a server then you'll need to use e.g. POST or PUT, not GET

https://www.w3schools.com/tags/ref_httpmethods.asp

Lipsitz
Advocate I
Advocate I

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.

 

2021-04-13 14_32_51-Test API _ Power Automate Desktop.png

fraenK
Super User
Super User

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

 

 

Lipsitz
Advocate I
Advocate I

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?

This fixed the issue.

Thanks!

Anonymous
Not applicable

Disabling "Encode request body" worked for me too.

 

Cheers All 🙂

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (2,354)