Update: Need add "extendAdminPermissions": true in request body to change dashboard owner
Hi guys
I'm trying to delete hundreds of private dashboards as admin, but #api-rest-api-3-dashboard-id-delete gives me error about "You may only create, modify or delete dashboards that you own."
so I try to change all of those dashboard's owner to myself, use #api-rest-api-3-dashboard-bulk-edit-put with below payload:
{
"action": "changeOwner",
"entityIds": [
110000,
111111,
222222
],
"changeOwnerDetails": {
"autofixName": true,
"newOwner": "1a2b3cxxxxxxx" (got this by accountId in #api-rest-api-3-myself-get)
}
}
but it returns with error message: "Only admin or owner of dashboard can change owner."
I'm very sure about the admin part, as I can change owner of those dashboards in admin page, anything wrong with my API request?
This is the curl format of my request:
curl -X "PUT" "https://aspiraconnect.atlassian.net/rest/api/3/dashboard/bulk/edit" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-u 'username:password' \
-d $'{
"action": "changeOwner",
"entityIds": [
11111,
22222,
33333
],
"changeOwnerDetails": {
"autofixName": true,
"newOwner": "1a2b3cxxxxxxx"
}
}'
Hi @Haishen
I understand you are trying to change the owner of a dashboard via the REST API. However given the error, I think the problem might be more of an authorization problem with REST. I tested this in my own site, and found I could change the owner with a curl request like this one:
curl --request PUT \
--url 'https://[mycloudsite].atlassian.net/rest/api/3/dashboard/bulk/edit' \
--header 'Authorization: Basic [encoded key redacted]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"action": "changeOwner",
"entityIds": [
10100
],
"extendAdminPermissions": true,
"changeOwnerDetails": {
"autofixName": true,
"newOwner": "my atlassian account id"
}
}'
For my result, curl returned a statement of:
{"action":"changeOwner","entityErrors":{}}%
And I then found these private dashboards were visible to my user as the owner.
There is one parameter my request has that yours does not,
"extendAdminPermissions": true,
Try adding that to your request. It's possible you are a Jira Admin, but might not be a site-admin, in which case there might be a permissions limitation here. If it's still not working, then try the steps below:
In your example, I see you appear to be using the -u switch. I'd recommend instead generating an API Token first. And then following the guide closely in https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/
This alternative authorization method suggests taking your email address, pairing that value with the token, and then encoding it in a base64 string that you can then pass as a header instead of using the -u switch.
Andy
A big thank you to Andy.
Adding
"extendAdminPermissions": true
was exactly what I was missing. After adding this field, changing the owner succeeded. Now I can delete those hundreds of dashboards. Thank you very much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Haishen,
Your curl request looks correct, comparing it to the API docs.
I have requested Atlassian support take a look at this request to see it they can suggest further, why it is not working as expected.
I hope this helps.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.