Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Send web request Automation using x-www-form-urlencoded

ginxx009 October 6, 2022

so in postman i have this POST REQUEST METHOD with the following urlencoded

POST -> URL: www.xxxxxxxxx.xxx/api/now/get_token_here

 

Body -> x-www-form-urlencoded

 

grant_type = password

client_id = client_id

client_secret = client_secret

username = username

password = password

 

now on my headers
Untitled.png

 

Now I am trying to use automation wherein I can get the {{weebhookResponse.body.access_token}}  then put it on another send web request automation like this

Untitled2.png

Untitled3.png

 

now it always gets me an error on the first send web request wherein I cannot get the token because it is giving me a 401 though it is working on the POSTMAN. Kindly help  

3 answers

4 votes
Rik de Valk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 27, 2023

Hi @ginxx009 , considering how long ago you posted this, you might have either fixed it, or given up :)
But I stumbled upon your question because I was struggling with it myself. 
It looks like you're initiating an OAuth flow to get a refresh token. 

I've managed to do this with Jira automation in this way: 

Create one action per parameter 'Create variable'. For example: 

  • variableName = clientId
  • Smart value = y0urSup3rS3cret1D

You do the same for clientSecret and password. 

After that you create the Send Webrequest action, with the header: 

Content-Type = application/x-www-form-urlencoded

And a Custom body like this where you put your parameters using your variables with the addition of the .urlEncode function for Smart Values. Your body would look somewhat like this: 

grant_type=password&client_id={{clientId.urlEncode}}&client_secret={{clientSecret.urlEncode}}&username=api_user_sn_chg_rest&password={{password.urlEncode}}

 

Happy Friday! 

Salomon Häseli September 25, 2023

Thank you very much! Works like a charm and saved me a lot of time

0 votes
Edwin van der Hoeven August 11, 2023

Thanks for the post.. saved me a lot of time figuring out. Wanted to connect with Stibo STEP and managed to do so with this help. 

0 votes
ginxx009 October 6, 2022

forgot to share the error

Send web request

Error publishing web request. Response HTTP status:

401

Error response HTTP body:

{"error_description":"access_denied","error":"server_error"}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events