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

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,043 views 13 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot