cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JoshBee
Frequent Visitor

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
fraenK
Memorable Member
Memorable Member
9 REPLIES 9
fraenK
Memorable Member
Memorable Member

Did you specify the content type header ?

 Content-Type: application/json; charset=UTF-8
Lipsitz
Helper I
Helper 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

fraenK
Memorable Member
Memorable Member

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
Helper I
Helper 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
Memorable Member
Memorable Member

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
Helper I
Helper 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?

fraenK
Memorable Member
Memorable Member

This fixed the issue.

Thanks!

JoshBee
Frequent Visitor

Disabling "Encode request body" worked for me too.

 

Cheers All 🙂

Helpful resources

Announcements
MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (98,220)