Forums

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

Rest API - Not getting accountId web response

DL_PGF December 26, 2023

I'm trying to pull out the accountId based on an email address using automation.

  1. My web request url is <jira_url>/rest/api/3/user/search?query={{issue.customfield_10094.urlEncode}}
  2. Http method: GET
  3. Web response body: Issue data (Jira format)
  4. Headers
    1. Authorization: basic <api_token>
    2. Accept: application/json

When i try to validate web request config with a project key, I see the payload with my custom field value:

"customfield_10094": "my_email@email.com",

But when I log {{webResponses.body.first.accountId}}, it turns up empty. What am I doing wrong?

 

1 answer

1 accepted

2 votes
Answer accepted
Fernando Eugênio da Silva
Community Champion
December 26, 2023

@DL_PGF 

I have the same API using this:

  1. My web request url is <jira_url>/rest/api/3/user/search?query={{issue.customfield_XXXX.urlEncode}}
  2. Http method: GET
  3. Web request body: EMPTY
  4. Headers
    1. Authorization: basic <api_token>
    2. Accept: application/json

And finally I'm get the web response using this variable: {{webResponse.body.accountId}}

Seeing your details, maybe you just need to avoid to get first in your web request response.

Have you tried this?

DL_PGF December 27, 2023

I updated with Web request body: EMPTY and {{webResponse.body.accountId}}, but still getting an empty value. 

Audit logs:

Action details:

USER CONDITION

The following issues passed:

<key>

SEND WEB REQUEST

Successfully published web request

LOG ACTION

Log

my_email@email.com (customfield_10094) and <EMPTY> {{webResponse.body.accountId}}

DL_PGF December 27, 2023

I've also tried {{webResponse.body.emailAddress}} and {{webResponse.body.accountType}} and it returns nothing.

 

When I do run <jira_url>/rest/api/3/user/search?query=my_email@email.com, I get a json response and can see accountId, emailAddress, accountType and lots of other data.

DL_PGF December 27, 2023

I have a suspicion that my headers are not correct, even though I get a 200 response. Can you give me an example of how it should be?

Fernando Eugênio da Silva
Community Champion
December 27, 2023

@DL_PGF 

To Header I'm using my token converted to base64. Similar to this: Basic XXXXX.

You can conver get this base64 converted token in Postman headers if you're using Postman to test or you can generate a base64 token converted using some websites, like this one: https://base64.guru/converter

In the left side fill the box with the content: your-email:your_api-tokenClick to encode to base64. Then copy the result and in your automation your header need to be like this:

Basic your-token-x64

Here a full print of my automation rule to test it.

URL: https://jira_site/rest/api/3/user/search?query={{issue.customfield_XXXX}}

Method: GET

Web Request Body: EMPTY

And ensure that you has checked the option: Delay execution of subsequent rule actions until we've received a response for this web request

Screenshot_161.png

 

And it works perfectly. Could you review your web request and response body to ensure that is similar as this one?

Like brian.g likes this
DL_PGF December 27, 2023

thank you so much! I got it working now. Sooo appreciate you!

Andrés Enrique Cárdenas
Contributor
January 30, 2024

thank you Fernando, encoding in 64  your-email:your_api-token also solved the issue for me

Like # people like this

Suggest an answer

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

Atlassian Community Events