How to stop sharing using API

Hi
Currently I want to use API to stop sharing a resource to a group like on this screenshot: click the cross button to remove a group from current resource.


It might be related to this issue: How can I delete a permission using the API?
I saw the reply is push the updated permissions using the share endpoint
So How could I implement that since I can’t find this on document, the only example is how to simulate share a resource to group, could you maybe instruct me how to remove sharing?
Thank you!

@kyxyes in order to remove a permission you need to call the share endpoint. You basically resend the permission you want to delete with the "delete": true flag. For example:

(Edited from POST to PUT)

PUT /share/resource/<uuid_of_resource>.json?api-version=2
{
   "permissions":[
      {
         "id":"40e26b09-8ed0-5d15-9b0c-d595bbb3cfe4",
         "aco":"Resource",
         "aco_foreign_key":"690b6e40-f371-579c-b0c6-86e8ef383adc",
         "aro":"User",
         "aro_foreign_key":"e97b14ba-8957-57c9-a357-f78a6e1e1a46",
         "type":7,
         "delete":true
      }
   ]
}
2 Likes

@remy Hi Thank you so much!
I tried POST but this method does not work for me, it returns 404 error.
But PUT method with the API url and the flag you gave me can successfully remove the shared resource.

1 Like