Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Add Project Role to Filter via REST API

cprime_eip
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 23, 2019

Hello.  I am unable to add a project role to a filter via Jira REST API with the following:

POST /rest/api/2/filter/{filterID}/permission

{
"type": "project_role",
"projectId": 10003,
"projectRoleId" : 10002,
"view": true,
"edit": false
}

The API return with the following error:
{
"errorMessages": [
"Invalid type given. Should be one of [PROJECT, GROUP, PROJECT_ROLE, GLOBAL, AUTHENTICATED, USER]"
],
"errors": {}
}

I've tried both upper and lower case "project_role" with no avail.  Is this an issue with my JSON format or a Jira bug?  I've tried this on v7.12.3 and v7.13.1.  Thanks.

2 answers

1 accepted

0 votes
Answer accepted
Earl McCutcheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 24, 2019

Hi Ed,

You are going to want to set the type to projectRole and the projectId for the project that the role is in and use projectRoleId for the id of the role like the following exe and it should do the trick:

{
"type":"projectRole",
"projectId":"10003",
"projectRoleId":"10002"
}

A full exe curl would look like this:

curl -D- -u user:pass -X POST --data '{"type":"projectRole","projectId":"10003","projectRoleId":"10002"}' -H "Content-Type: application/json" "http://BASE_URL/rest/api/2/filter/{filterID}/permission"

I'm sure you probably already have the following but just adding this in for referance incase anyone comes across this post, additional details on the endpoint can be seen at the following link:

Regards,
Earl

0 votes
cprime_eip
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 24, 2019

Ahhh, "type":"projectRole"!  So this looks like a minor bug in previous versions (and potentially latest as well).  Notice the error message said PROJECT_ROLE, and documentation is lacking around the valid types.  

{
"errorMessages": [
"Invalid type given. Should be one of [PROJECT, GROUP, PROJECT_ROLE, GLOBAL, AUTHENTICATED, USER]"
],
"errors": {}
}

 

Also, for anyone else looking for this, it MUST be projectRole in camel casing. 

Regardless, thanks!

Ed

Earl McCutcheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 24, 2019

Hi Ed,

Good catch I totally missed that, and yeah that would be a bug for the error output and that should read with the appropriate value, I created a bug report to track this here:

Regards,
Earl

Suggest an answer

Log in or Sign up to answer