I pass the exact data that is provided in the example: https://docs.atlassian.com/software/jira/docs/api/REST/7.12.1/#api/2/filter-addSharePermission
I get an error that appears to say is does not want to work with an array:
"Can not deserialize instance of com.atlassian.jira.rest.v2.search.SharePermissionInputBean out of START_ARRAY token\n at [Source: org.apache.catalina.connector.CoyoteInputStream@4af39074; line: 1, column: 1]"
If I provide only a single object, it takes it.
The problem is that if I apply multiple objects each one will overwrite the other. Seems I cannot apply multiple types of permissions to the same filter.
Anyone have it working?
For posterity (at least on 7.12.3, not sure about later releases), when applying filter permissions via REST API:
Thanks to @Earl McCutcheon for the quick response, which probed me in the right direction to piece this together. Especially 3-5 above which almost made me lose my mind :)
Hi Jorge,
The error that you are receiving looks like it might be a syntax error on the surface.
I just did a CURL to the endpoint on a test instance using a group as the input for the data variable in the following format with a single variable and it went through without issue:
curl -D- -u user:pass -X POST --data '{"type": "group","groupname": "jira-administrators","view": true,"edit": false}' -H "Content-Type: application/json" "http://1{BASE_URL}/rest/api/2/filter/{ID}/permission"
And a double variable of group and user, which also went through OK:
-data '{"type": "group","groupname": "jira-administrators","view": true,"edit": false},{"type": "user","userKey": "admin","view": true,"edit": true}'
What is the format of your query particularly the data variable?
Regards,
Earl
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Earl McCutcheon , thanks for following up. Not entirely due to syntax error, but I now fix my original problem with a realization I just had, applying type:"authenticated" wipes out all permissions, so applying that first and then other individually works. Also you cannot apply multiple permissions at the same time, only the first is applied!
In summary (my Jira is version 7.12.3):
DETAILS (note use of bash variables to protect the innocent):
1. BUG #1: Brackets cause ERROR (REST docs example show they should be accepted):
$ echo "Start with private (no permissions) filter"
Start with private (no permissions) filter
optadmin@172.25.35.70 bvafcmd01 DEV [Thu Aug 08 20:03:12] ~/REST/jira/create_pmo_dash
$ curl -s -w "\n%{http_code}" -u $myuser:$mypwd -X GET "https://${myurl}/rest/api/2/filter/28536/permission" | { read body; read code; echo "$code"; jq <<< "$body"; }
200
[]
$ curl -s -w "\n%{http_code}" -u $myuser:$mypwd -X POST --data '[ {"type":"group","groupname":"jira-administrators","view":false,"edit":true},{"type":"group","groupname":"PMO","view":true,"edit":false} ]' -H "Content-Type: application/json" "https://${myurl}/rest/api/2/filter/28536/permission" | { read body; read code; echo "$code"; jq <<< "$body"| sed -e "s/$myurl/<myurl>/g" -e "s/$myuser/<myuser>/g"; }
400
{
"errorMessages": [
"Can not deserialize instance of com.atlassian.jira.rest.v2.search.SharePermissionInputBean out of START_ARRAY tokenn at [Source: org.apache.catalina.connector.CoyoteInputStream@79160be6; line: 1, column: 1]"
]
}
2. BUG #2: Multiple objects without brackets are accepted, but only the first is processed:
$ curl -s -w "\n%{http_code}" -u $myuser:$mypwd -X GET "https://${myurl}/rest/api/2/filter/28536/permission" | { read body; read code; echo "$code"; jq <<< "$body"; }
200
[]
optadmin@172.25.35.70 bvafcmd01 DEV [Thu Aug 08 20:03:28] ~/REST/jira/create_pmo_dash
$ curl -s -w "\n%{http_code}" -u $myuser:$mypwd -X POST --data ' {"type":"group","groupname":"jira-administrators","view":false,"edit":true},{"type":"group","groupname":"PMO","view":true,"edit":false} ' -H "Content-Type: application/json" "https://${myurl}/rest/api/2/filter/28536/permission" | { read body; read code; echo "$code"; jq <<< "$body"| sed -e "s/$myurl/<myurl>/g" -e "s/$myuser/<myuser>/g"; }
201
[
{
"id": 34458,
"type": "group",
"group": {
"name": "jira-administrators",
"self": "https://<myurl>/rest/api/2/group?groupname=jira-administrators"
},
"view": true,
"edit": false
}
]
3. BUG #3: view=false,edit=true results in opposite application for groups. For users, it properly returns an error.
<See BUG #2, I passed view=false and edit=true, but returned output shows the opposite! >
4. Inconsistent data, input, output:
UI view permission for all logged in users shows "Shared with logged-in users", REST GET returns type="loggedin":
$ curl -s -w "\n%{http_code}" -u $myuser:$mypwd -X GET "https://${myurl}/rest/api/2/filter/28536/permission" | { read body; read code; echo "$code"; jq <<< "$body"; }
200
[
{
"id": 34459,
"type": "loggedin",
"view": true,
"edit": false
}
]
But applying type="loggedin" returns error:
$ curl -s -w "\n%{http_code}" -u $myuser:$mypwd -X POST --data '{"type":"loggedin","view":true,"edit":false}' -H "Content-Type: application/json" "https://${myurl}/rest/api/2/filter/28536/permission" | { read body; read code; echo "$code"; jq <<< "$body"| sed -e "s/$myurl/<myurl>/g" -e "s/$myuser/<myuser>/g"; }
400
{
"errorMessages": [
"Invalid type given. Should be one of [PROJECT, GROUP, PROJECT_ROLE, GLOBAL, AUTHENTICATED, USER]"
],
"errors": {}
}
Error message shown above implies GLOBAL and AUTHENTICATE are different, but applying type="authenticated" results in wiping all other permissions, which is what the REST docs state is the behavior of authenticated!!!
$ curl -s -w "\n%{http_code}" -u $myuser:$mypwd -X POST --data '{"type":"group","groupname":"jira-administrators","view":false,"edit":true},{"type":"group","groupname":"PMO","view":false,"edit":true}' -H "Content-Type: application/json" "https://${myurl}/rest/api/2/filter/28536/permission" | { read body; read code; echo "$code"; jq <<< "$body"| sed -e "s/$myurl/<myurl>/g" -e "s/$myuser/<myuser>/g"; }
201
[
{
"id": 34462,
"type": "group",
"group": {
"name": "jira-administrators",
"self": "https://<myurl>/rest/api/2/group?groupname=jira-administrators"
},
"view": true,
"edit": false
}
]
$ curl -s -w "\n%{http_code}" -u $myuser:$mypwd -X POST --data '{"type":"group","groupname":"PMO","view":false,"edit":true}' -H "Content-Type: application/json" "https://${myurl}/rest/api/2/filter/28536/permission" | { read body; read code; echo "$code"; jq <<< "$body"| sed -e "s/$myurl/<myurl>/g" -e "s/$myuser/<myuser>/g"; }
201
[
{
"id": 34463,
"type": "group",
"group": {
"name": "jira-administrators",
"self": "https://<myurl>/rest/api/2/group?groupname=jira-administrators"
},
"view": true,
"edit": false
},
{
"id": 34464,
"type": "group",
"group": {
"name": "PMO",
"self": "https://<myurl>/rest/api/2/group?groupname=PMO"
},
"view": true,
"edit": false
}
]
$ curl -s -w "\n%{http_code}" -u $myuser:$mypwd -X POST --data '{"type":"authenticated","view":true,"edit":false}' -H "Content-Type: application/json" "https://${myurl}/rest/api/2/filter/28536/permission" | { read body; read code; echo "$code"; jq <<< "$body"| sed -e "s/$myurl/<myurl>/g" -e "s/$myuser/<myuser>/g"; }
201
[
{
"id": 34465,
"type": "loggedin",
"view": true,
"edit": false
}
]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.