cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to convert x-www-form-urlencoded (Postman) to WebApi

rgj
Level 2
Hi, anyone who knows how to "convert" my Postman POST command to BP Web api format?

In Postman, the keys are in Body as x-www-form-urlencoded.

Converted to CURL (it looks like this):
curl --location --request POST 'https://xxxx' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=xxx' \
--data-urlencode 'scope=xxx' \
--data-urlencode 'username=xxx' \

In BP Web api \ Request\ Body content \ Template, I have tried both format 'key1=[value1]'&'key2=[value2]' and JSON format like { "key1": "[value1]", "key2": "[value2]"} (Content-Type= application/x-www-form-urlencoded and application/json).

Both elternatives return HTTP 400 error (which is syntax error, I quess).



------------------------------
Ruben Gjelsten
Senior Analyst Service Management
SSV IIC RPA
Europe/London
------------------------------
16 REPLIES 16

Hi Ruben,

You can add the parameters in the URL path like https://xxxx/?key1=[value1]&key2=[value2] with Body Content set to None.

------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
------------------------------

I have the same question as Ruben. I tried the solution that Shashank recommended, but that did not work either. I get a 404 Not Found message returned: "No resources match requested URI"

------------------------------
Jenna Jentges
Financial Analyst
CUNA Mutual Group
America/Chicago
------------------------------

You can create a body template and place the parameters in the body in a similar format to how you'd define them as query parameters. This is how your making an HTTP POST. Here's a body template example:

grant_type=[Grant Type]&client_id=[Consumer Key]&client_secret=[Consumer Secret]&username=[Username]&password=[Password]

Cheers,

------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------

Hi Ruben,

As well as what Eric has mentioned you should also make sure that the header is set in either each action or in the API service such as below.30552.pngIf this doesn't work then you should look to select the "Enable Request Data Output Parameter" tick box under the action so you can see what you are sending and match it to the postman output.

Hope this helps

------------------------------
Ronan Considine
Blue Prism
------------------------------
Ronan Considine Senior Business Analyst Blue Prism

Hi,

I am facing an interesting issue with a POST to get the access token to interact with Sharepoint list. The call is currently working in Postman but not in BP webservices.

The error I am getting is as follows:
--------------------------------------------------
HTTP Status Code: 400
HTTP Response Content: {"error":"invalid_request","error_description":"AADSTS900144: The request body must contain the following parameter: 'grant_type'.......
-------------------------------------------------

The URL I am using is = https://accounts.accesscontrol.windows.net/[TID]/tokens/OAuth/2

Body (Template):
{
"grant_type": "client_credentials",
"client_id": "[XXXXX]",
"client_secret": "[XXXXX]",
"resource": "00000003-0000-0ff1-ce00-000000000000/[XXXXX.com]@[XXXXX]"
}

Header:
30554.png
Every time I run this it fails with the error above but it works perfectly in postman. Are you in a good position to support me with this?


------------------------------
Kapeteni Polutea
Technical Consultant
EY
Australia/Sydney
------------------------------

Hi Kapeteni,

The body template should be in this format

grant_type=[client_credentials]&client_id=[XXXXX]&client_secret=[XXXXX]&resource=00000003-0000-0ff1-ce00-000000000000/[XXXXX.com]@[XXXXX]

------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
------------------------------

Hi Kapeteni,

www form urlencoded uses a slightly different language which Postman converts between however BluePrism does not.

What you will need to do it to convert your body from JSON into this new format as Shashank has detailed. Postman allows you to select between JSON and raw text but BluePrism will automatically convert this so you just need to put the text with appropriate values but without quotation marks

------------------------------
Ronan Considine
Business Automation Lead
Blue Prism
------------------------------
Ronan Considine Senior Business Analyst Blue Prism

Shashank Kumar and Ronan Considine - Thank you both for your support. This is now working for me.

Appreciate this community 🙂

------------------------------
Kapeteni Polutea
Technical Consultant
EY
Australia/Sydney
------------------------------

Hi Ronan, 

I have a similar problem but I cannot solve it with what you have proposed, I have my request in postman and it works as expected:
30559.png
30560.png
30561.png
30562.png
30563.png
30564.png
I am receiving "Internal : Unexpected error Error during Web API HTTP Request
HTTP Status Code: 400
HTTP Response Content: Bad Request"

I am not sure if my problem is related with the Authorization or with the Body itself. Do you know what could be wrong? It would be very helpful if you could give me a hand,

Thank you in advance.


------------------------------
Jesus Jordan
------------------------------