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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,467,457
Community Members
 
Community Events
177
Community Groups

How to update/add scope to project role created using API?

Hi,

I've been exploring and try the Jira rest api to adjust things on my org. and I need some insight for Project Role API.

On the docs we can create and update (fully or partially) project role by the ID, my concern is the payload from creating the new project role are just name and description . I need to create roles specified on project as this is possible on the GUI panels and also there is this scope object we can obtain on GET .

 

I've tried adding the scope on the payload but it didn't work, is there any workaround I can do to add the scope? Thanks.

1 answer

0 votes
Andy Heinzer Atlassian Team Dec 10, 2021

Hi Arsen,

I understand that when you make a REST call to the POST /rest/api/3/role endpoint you are not seeing a response that includes the role's id.  I tested in this my own Cloud site using basic auth, but I did get back a self, name, id, and description here.

In my test I was using curl to make this call.  I would be interested to learn what client you are using to make this REST call.  In some cases some clients are not always setup to listen for a response for a POST or PUT call, so it might be something to do specifically with the client making this REST call.

It's not possible to add actors to a new role in the first call that creates that role.  This is actually by design, and there is a note about this in the REST reference:

Note that although a new project role is available to all projects upon creation, any default actors that are associated with the project role are not added to projects that existed prior to the role being created.<

I hope that helps.

Andy

Hi Andy,

actually I'm using postman for the REST call. But my question is there a possible way to update or insert scope into role created ?

 

I want the role only affect the some/ one project, not globally

Andy Heinzer Atlassian Team Dec 14, 2021

I guess I'm confused by the term scope here.  Are you asking how to change that role within a single project?

The roles are only expected to contain either groups or individual user accounts.  The endpoint POST /rest/api/3/project/{projectIdOrKey}/role/{id} will let you add users/groups to that role. But that endpoint is not a global change, it only applies to the specific project passed in the {projectIdOrKey} element of the URI.

ooh.. sorry for the confusion.

I mean this API to create role Andy, 

It only contains name and description, and its the same for update role API which means the role created using that will have no scope of specific project ID on it.

I tried to change the payload like this, but it didn't work

Screen Shot 2021-12-15 at 09.39.02.png

Andy Heinzer Atlassian Team Dec 16, 2021

Thanks for the additional explanation. When doing a GET to that endpoint, you can sometimes get back a scope that will show you which project is using that role.  However the POST of that same endpoint doesn't accept a scope value as input at any time (during creation or later).

So far, the only time I have seen that scope value is when performing a GET to that endpoint and then it still only shows for roles created within a team-managed project.  In my own testing, I created a new role in a team-managed project in the web UI, and then called the GET REST API endpoint /api/3/role to see this scope.

Since the REST API is expecting to create global roles when calling the create endpoint, it doesn't seem like this is something that can be set from this endpoint.  The very nature of team-managed projects means that roles created there are not expected to be able to be global in nature and hence these scope help make it clear that these roles are specific to that project.  More details on the differences between these projects types can be found in What are team-managed and company-managed projects? .

Sorry if this doesn't provide the answer you are looking for, but I don't think it is possible to do this for a role created via the REST API.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events