Forums

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

I am getting 404 error for rest api on JIRA to search an user accountID

Ujala Singh February 9, 2022

I want to test the rest api of jira and fetch user accountID from jira.

So I used the below url 

url: 'https://domain.atlassian.com/rest/api/2/user/search%3Fquery=myuser@domain.com'

But I am getting 404 ,

req: {
method: 'GET',
body: undefined,
url: '***/rest/api/2/user/search%3Fquery=myuser@domain.com'
},

1 answer

0 votes
Hana Kučerová
Community Champion
February 10, 2022

Hi @Ujala Singh ,

welcome to the Atlassian community!

The probable reason, you are getting error 404, is you have %3F (encoded version of ?) instead of ? in your URL.

The URL should be:

https://domain.atlassian.com/rest/api/2/user/search?query=myuser@domain.com

Ujala Singh February 10, 2022

Hi @Hana Kučerová , I am using that only here. While running the github action, it's encoding it, not sure why. 

Error: Jira API error
at Jira.fetch (/actions-runner/_work/_actions/ujala-singh/selfhosted-jira-accountID/master/dist/index.js:1:104085)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
req: {
method: 'GET',
body: undefined,
url: '***/rest/api/2/user/search%3Fquery=myuser@domain.com'
},
res: {
headers: [Object: null prototype] {
server: [Array],
vary: [Array],
'cache-control': [Array],
'content-type': [Array],
'content-encoding': [Array],
'strict-transport-security': [Array],
date: [Array],
'atl-traceid': [Array],
'x-arequestid': [Array],
'x-aaccountid': [Array],
'x-xss-protection': [Array],
'transfer-encoding': [Array],
'timing-allow-origin': [Array],
'x-envoy-upstream-service-time': [Array],
'x-content-type-options': [Array],
connection: [Array],
'set-cookie': [Array],
'expect-ct': [Array]
},
status: 404,
body: '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>404</status-code><message>null for uri: ***/rest/api/2/user/search%3Fquery=myuser@domain.com</message></status>'
},
originError: Error: Not Found
at /actions-runner/_work/_actions/ujala-singh/selfhosted-jira-accountID/master/dist/index.js:1:97661
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Jira.fetch (/actions-runner/_work/_actions/ujala-singh/selfhosted-jira-accountID/master/dist/index.js:1:103974)
at async e.exports.execute (/actions-runner/_work/_actions/ujala-singh/selfhosted-jira-accountID/master/dist/index.js:1:242679)
at async exec (/actions-runner/_work/_actions/ujala-singh/selfhosted-jira-accountID/master/dist/index.js:1:8689),
source: 'jira'
}
Hana Kučerová
Community Champion
February 19, 2022

Hi @Ujala Singh ,

I suspect this code 

const url = format({
host: host || this.baseUrl,
pathname,
query,
})

is causing it.

I believe you don't have your variables in getAccountID correct, see here. Probably it should be something like:

pathname: `/rest/api/2/user/search`
query: `query=${useremail}`
Ujala Singh June 18, 2022

@Hana Kučerová Hi sorry for the delayed response:

 

I am using this:

async getAccountID (useremail) {
return this.fetch('getAccountID', {
pathname: `/rest/api/2/user/search?query=${useremail}`,
}, {
method: 'GET',
})
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events