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

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

arsen.davidson December 8, 2021

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
Atlassian Team members are employees working across the company in a wide variety of roles.
December 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

arsen.davidson December 12, 2021

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
Atlassian Team members are employees working across the company in a wide variety of roles.
December 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.

arsen.davidson December 14, 2021

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.

arsen.davidson December 14, 2021

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
Atlassian Team members are employees working across the company in a wide variety of roles.
December 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
AUG Leaders

Atlassian Community Events