Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

ginxx009
Contributor
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

1 accepted

5 votes
Answer accepted
Rik de Valk
Community Champion
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! 

Sal
Contributor
September 25, 2023

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

0 votes
Edwin van der Hoeven
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
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
Contributor
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
Product Admin
TAGS
AUG Leaders

Atlassian Community Events