Hello I'm trying to set project members as editors in python script, but nothing seams to work (looks like possible bug in REST API)
What I've tried:
1. (Worm up) Uodate filter by: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-filters/#api-rest-api-2-filter-id-put
Edited field: sharePermissions , but off course that didn't worked.
2. Add permissions by: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-filter-sharing/#api-rest-api-2-filter-id-permission-post
This went much better. I was able to add some sharing using example from rest api manual with params:
payload = json.dumps( {
"type": "project",
"projectId": "123123"
} )
but that worked only for viewers , but I need to add write(edit) permissions as well.
3. I found extra field to edit rights (poorly documented but that's not a problem in my case) so I modified above request like:
payload = json.dumps( {
"type": "project",
"projectId": "123123",
"rights": {"value":3}
} )
Why "rights": {"value":3} ? I found it in request on jira web interface when I was updating permissions manually. I've also tried to
pass just number. Whatever I used, i got error:
{
"errorMessages": [
"Unrecognized field \"rights\" (Class com.atlassian.jira.rest.v2.search.SharePermissionInputBean), not marked as ignorable\n at [Source: org.apache.catalina.connector.CoyoteInputStream@1414fb89; line: 1, column: 70] (through reference chain: com.atlassian.jira.rest.v2.search.SharePermissionInputBean[\"rights\"])"
]
}
4. I also tried to change "rights" to "edit": True, that was run successfully but edit field was skipped, and in share object I get, I still had: "edit": false, . I also verified this by web interface.
BTW, when I tried to use anything else then bool value for edit, I got error:
{
"errorMessages": [
"Can not deserialize instance of boolean out of START_OBJECT token\n at [Source: org.apache.catalina.connector.CoyoteInputStream@1414fb89; line: 1, column: 41] (through reference chain: com.atlassian.jira.rest.v2.search.SharePermissionInputBean[\"edit\"])"
]
}
5. I also tried a lot of variants where I tried to edit sharePermission using "PUT" and url = "https://some.jira.com/rest/api/2/filter/123123/permission/45645"
and many more, but every time I've tried something like this, I've got response 405
Do You have any idea, how should I use it?
Apparently the payload need to have both permissions declared:
payload = json.dumps( {
"type": "project",
"projectId": "123123",
"view": True,
"edit": True,
} )
After that API started to do what I've asked. Strange... Nevertheless Thank You atlassian for very well documented API, I just wasted only 1 day-work to figure this out...
Hi @Paweł Połeć , did you try the same for sharing edit permissions with a user?
End point: "https://your-domain/rest/api/3/filter/{id}/permission"
I tried
payload = json.dumps( {
"type": "user",
"accountId": account_id,
"view": True,
"edit": True
} )
Which is giving me this error
{ "errorMessages": [ "Unrecognized field \"view\" (Class com.atlassian.jira.rest.v2.search.SharePermissionInputBean), not marked as ignorable\n at [Source: org.apache.catalina.connector.CoyoteInputStream@159d7a07; line: 1, column: 71] (through reference chain: com.atlassian.jira.rest.v2.search.SharePermissionInputBean[\"view\"])" ] }
Could you please check if you encountered the same error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Vidyush Bakshi unfortunately only group sharing was my target. I reviewed your proposal and it seems quite OK according to documentation. Unluckily right now I don't have environment where I could check your solutio
But what can I suggest: keep in mind, that account_id should be a string value not number. So it would be looks like:
"accountId": "25326",
remember about quote marks or casting it to str.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your response @Paweł Połeć , but still it is not working and giving #400 response. I am not sure what am I doing wrong.
{ "errorMessages": [ "Unrecognized field \"view\" (Class com.atlassian.jira.rest.v2.search.SharePermissionInputBean), not marked as ignorable\n at [Source: org.apache.catalina.connector.CoyoteInputStream@5bbf7456; line: 1, column: 71] (through reference chain: com.atlassian.jira.rest.v2.search.SharePermissionInputBean[\"view\"])" ] } <Response [400]>
This is the only error I am getting and if change view to edit it throws same error for edit.
accountId is in str as you said. As it is not working for user, I am not sure if it will work for group in my case.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
well, I would also try option with "rights": {"value":3} instead edit/view. That's last what in my head. Fingers crossed, let me know if it worked
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is still not working :'/.
{ "errorMessages": [ "Can not deserialize instance of java.lang.Integer out of START_OBJECT token\n at [Source: org.apache.catalina.connector.CoyoteInputStream@19dc6a12; line: 1, column: 57] (through reference chain: com.atlassian.jira.rest.v2.search.SharePermissionInputBean[\"rights\"])" ] } <Response [400]>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
groupId=<groupId>
curl ... --data "$(jq -n --arg groupId ${groupId} '{ "rights": 3, "type": "group", "groupId": $groupId }')"
yes, this worked for me to add edit permissions to group <groupId>.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is my answer with examples of adding filter share permissions to project, user. group of users, all logged-in JIRA users and all web users:
https://community.atlassian.com/t5/Jira-Software-questions/Re-rest-api-how-to-set-sharePermissions-for-a-project/qaq-p/2653916/comment-id/935465#M935465
It helps by some questions raised here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
to whom it may concern:
I also tried to change the permissions according to a filter. "Members" of a specific project should be able to view the filter. My solution concerning the payload:
payload = json.dumps( {
"projectId": <your projectId>,
"type": "project",
"rights": "1"
} )
The trick was to treat the value for "rights" as a string (not as an integer). When I used
"rights" : 1
it did not work.
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.