Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to Add actors to project using REST API (curl)

Gowri I'm New Here Jun 22, 2021

Hello, 

I would greatly appreciate if anyone could help me figure out how to add actors to a project. Do we need to create different roles for each project ?

 

I tried this  : 

End point: url+ rest/api/3/project/10007/role/10013

Content:

{
"actors": [
{
"accountId" : "6091b9e70bXyyyzzzz" //with a valid ID
}
]
}

Have proper valied header values and authentication set.

 

Regards,

Gowri

 

1 answer

1 accepted

1 vote
Answer accepted
Andy Heinzer Atlassian Team Jun 24, 2021

Hi,

I see that you are wanting to add actors to a project role using the REST API.  To answer your question, you do not need to create new roles for each project, as by default each project will have a few different roles such as "Administrators" and "Developers".  Typically you can just choose one of those roles, unless you need some more level of granular controls for users.  In which case, then it might be better to create a new role.

Once you have created the roles you want, then I suggest to find the correct ID of that role for that project, you can obtain that by calling the endpoint GET /rest/api/3/project/{projectIdOrKey}/role.  This can show you in the json payload which ID corresponds to which role.

To add an actor to an existing role (without removing all the others), use the endpoint POST /rest/api/3/project/{projectIdOrKey}/role/{id} 

you could also use the endpoint of PUT /rest/api/3/project/{projectIdOrKey}/role/{id} but please understand that if you use the PUT verb here, it sets that project role with your payload, thereby overwriting all other previously set values for that project role.

 

So if you want to just add a new actor, you need to use the POST endpoint here.  There is a curl example on that POST endpoint that shows how to add a group to a specific role:

curl --request POST \
--url 'https://your-domain.atlassian.net/rest/api/3/project/{projectIdOrKey}/role/{id}' \
--header 'Authorization: Basic [redacted]' \
--header
'Accept: application/json' \
--header
'Content-Type: application/json' \
--data
'{
"group": [ "jira-developers" ]
}'

and it also explains that you can use the "user" array if your object is not a group.  So your call in curl might look something like this:

curl --request POST \
--url 'https://your-domain.atlassian.net/rest/api/3/project/{projectIdOrKey}/role/{id}' \
--header 'Authorization: Basic [redacted]' \
--header
'Accept: application/json' \
--header
'Content-Type: application/json' \
--data
'{
"user": [ "6091b9e70bXyyyzzzz" ]
}'

Which will add that user to that project role without removing all other users from the the role.

Does that help?  Let me know if you run into any problems with this.

Andy

Gowri I'm New Here Jun 24, 2021

You are awesome Andy...!! Thanks for such detailed explanation. 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

872 views 2 22
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you