Forums

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

Error when using user search by query (Jira API 3)

Benja Stephens
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!
July 2, 2019

The steps I followed were as follows:

1. I defined the Jira Rest API scope to view user profiles (read:jira-user) 

2. I obtained an authorization code using the authorization URL

3. Exchanged the authorization code for a bearer token using the link: https://auth.atlassian.com/oauth/token

4. Used the bearer token to search for a user using the Query:

curl -X GET \
https://<site>.atlassian.net/rest/api/3/user/search?query=%'\
-H 'Accept: application/json' \
-H 'Authorization: Bearer  <Bearer Token>' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Host: <site>.atlassian.net' \
-H 'Postman-Token: 8cf2cf71-15b0-4e15-a7c1-65bf0be730ed,b63f2a6f-85fa-455a-b5f2-66088483c422' \
-H 'User-Agent: PostmanRuntime/7.15.0' \
-H 'accept-encoding: gzip, deflate' \
-H 'cache-control: no-cache' \
-H 'content-length: 23' \
-H 'cookie: atlassian.xsrf.token=BET3-9NB2-SL21-3ZD3_946fdfc8ec4999d356397800e32416b41fc70b82_lout' \
-b atlassian.xsrf.token=BET3-9NB2-SL21-3ZD3_946fdfc8ec4999d356397800e32416b41fc70b82_lout \

 

For that I get the response: 

[]

 

 

But I should be getting a list of 5 users instead.

Am I doing something wrong here? 

 

1 answer

0 votes
Ross McCoy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 1, 2019

Hello!

This might be an incredible over-simplification of your question, but I've tried multiple REST API user search queries on my Jira Cloud instance and the only response that returns all defined users is to leave the query blank:

https://<site>.atlassian.net/rest/api/3/user/search?query=

A caveat is that this introduces an additional problem, which is that all users returned via this query include users not visible via the UI, such as invisible users added via plugins. However, these users are limited in scope and you can usually programatically eliminate them depending on what you're trying to get from the search.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events