What's the right value for user, when adding user to role in project, using REST API ?

I'm currently building a small script that adds a user to a project's role, and I'm not sure about the user value.

I followed the documentation at https://docs.atlassian.com/jira/REST/cloud/#api/2/project/{projectIdOrKey}/role and in the Add Actors users, I currently provide the user key but the API keeps returning 404 (it works with groups !)

I've validated that the project existed, along with the role in the project (since the GET call returns fine & the POST failed with 404). I feel that I pass the wrong value in the user ({ "user" : ["admin"] })

Where should be the value & how could I get more info about the encountered error? (I call the API from Java using Jersey).

Thanks in advance,

1 answer

1 accepted

1 vote
Accepted answer

Hi Maxence,

This is working fine for me.
curl -u username:password -X POST --data '{"user" : ["admin"]}'  jiraurl/rest/api/2/project/projectkey/role/id -H'Content-type: application/json' -H'Accept: application/json'

Hello Swetha, 

I've tried and it also works for my for my admin & sysadmin... But not non-admin users...

Hi Maxcence,

It works for non admin users too for me. Can you paste the error here.

Nothing more than the 404..., when calling through Jersey (in Java)

When doing with cURL, I get the following 

{"errorMessages":["We can't find 'Maxence.Vanbesien' in any accessible user directory. Check they're still active and available, and try again."],"errors":{}}

While querying the user direclty https://.../jira/rest/api/2/user?username=Maxence.Vanbesien returns the right information ({"self":"https://kazan.atosworldline.com/jira/rest/api/2/user?username=Maxence.Vanbesien","key":"maxence.vanbesien","name":"Maxence.Vanbesien","emailAddress":"...","avatarUrls":{...},"displayName":"Maxence Vanbésien","active":true,"timeZone":"Europe/Paris","locale":"en_UK","groups":{"size":7,"items":[]},"applicationRoles":{"size":1,"items":[]},"expand":"groups,applicationRoles"})

Did you try with any other non-admin user other than maxence.vanbesien?

I think I found the solution...

The username should not be the name but the key (case is different in my case) and when using Jersey, we need to specify the type & the accept parameters (your cURL command gave me the clue)


Good to hear that :)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,301 views 12 19
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you