How to stop sharing using API

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

@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