Forums

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

How to query a user name by a display name

Alex Yang
Contributor
May 18, 2021

In our CI pipeline, when the unit test fails, we need to parse and get the commit's author such as "Alex Yang" (alias is alexya) who is also a Jira system user.

When I call Jira REST API to create an issue and set the assignee, it needs the "name" of the user in the Jira system such as "alexya" instead of a full or display name "Alex Yang". (using the name I can create the issue successfully, but displayName will fail)

e.g. 

POST /rest/api/2/issue

 

```

{
"fields": {
"project": {
"key": "AAAA"
},
"summary": "3rd task created with rest API",
"description": "creating of an issue using ids for projects and issue types using the REST API",
"issuetype": {
"name": "Bug"
},
"assignee": {
"displayName": "Alex Yang"
},
"priority": {
"id": "2"
}
}
}

```

It will fail with the error: 

```

{    "errorMessages": [],    "errors": {        "assignee""expected Object containing a 'name' property"    }}

```

 

Furthermore, I tried to use REST API to query the user information, but

the REST API GET /rest/api/2/user?username=alexya can only accept the parameter "username" or "key", can't use the displayName to query the details of a user so that I can't use the displayName to get the user name. e.g.

```

{    

"errorMessages": [        

"Either the 'username' or the 'key' query parameters need to be provided"    

],    "errors": {}}

```

 

Any help will be much appreciated. 

 

2 answers

0 votes
Hartwig B March 25, 2025
rest/api/latest/user/search?username={display_name}

 Works fine for me to search by a display name, e-mail address or name  

Piyush Annadate _ACE Pune_
Community Champion
May 11, 2025
"errorMessages":["The query parameter 'username' is not supported in GDPR strict mode."],"errors":{}}
0 votes
jpaige
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 4, 2021

I was looking for this too. Setting the assignee requires the accountId, but the commands to look up a user by displayName and/or emailAddress were removed for GDPR compliance

The only workaround I have found is that JQL queries still accept displayName or emailAddress.

So you can perform a query to match assignee or reporter in existing issues, and then extract the accountId from those results. It's a hack, and it only works for users who have had at least one issue assigned to them before, but it is better than nothing.

Here is a very quick-and-dirty snippit using jira's python api wrapper that gets the job done:

if '"' in username:
    return None
for field in ["assignee", "reporter"]:
    query = f'{field} = "{username}"'
    result = jira.jql(query, limit=1)
    issues = result.get("issues", [])
    for issue in issues:
        user_obj = issue["fields"].get(field, None)
        if user_obj:
            if username in [user_obj["displayName"], user_obj["emailAddress"]]:
                if user_obj["active"]:
                    return user_obj["accountId"]
Bryan Meyerovich September 11, 2022

Pulling the /users api endpoint seems to include display name, can maybe be parsed out of that?

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events