cannot delete a folder in communication site using sharepoint rest apis

Copper Contributor

I have a share-point account with admin priviledges.

I'm using share-point rest apis for deleting a folder in communication site.

I was able to create a folder in share-point communication site.

but couldn't do it for the already created folder for deletion.


following is rest end point



(above stars are placeholders)


I'm making a post request instead of delete in postman.


I have set the valid bearer token in the request header as well.


also following are the request headers which I have set.


If-Match -> *
X-RequestDigest -> some random string
Accept -> application/json;odata=verbose


when I'm sending the request I'm getting following error.


    "error": {
        "code": "-2147024891, System.UnauthorizedAccessException",
        "message": {
            "lang": "en-US",
            "value": "Access denied. You do not have permission to perform this action or access this resource."



I have already registered a share-point application in the azure directory as well.

and given the required permission.

below is the screenshot.




please any one give me what I'm doing wrong here.

any help would be appreciated.

2 Replies

@buddhika_jayakodi When using Postman you need to use a bearer token to access Sharepoint.
X-RequestDigest only works when you are communicating on Sharepoint with a logged in account.

Try using Ajax call in your console, then you can use x-requestdigest

@IshtarOnline , I have set the bearer token in the request header, but the same result.