Not able to rename folder using REST API using POSTMAN

Madhu Sudan Singh 61 Reputation points
2021-07-12T12:01:53.403+00:00

Hi All,

I am not Not to rename the folder using REST API using POSTMAN, Please refer to the below screenshot of my REQUEST

113894-capture.png

Microsoft 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft 365 and Office | SharePoint Server | Development
0 comments No comments
{count} votes

Answer accepted by question author
  1. MichaelHan-MSFT 18,136 Reputation points
    2021-07-13T03:54:40.037+00:00

    Hi MadhuSudanSingh-1785,

    You need to set the Content-Type header as application/json;odata=verbose, as the below:

    114045-image.png

    And the body:

    {  
            "__metadata": {              
                "type": "SP.Data.Shared_x0020_DocumentsItem"  
            },  
            "FileLeafRef": "NewFolderName"  
    }    
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Michael Taylor 61,111 Reputation points
    2021-07-12T14:04:50.06+00:00

    The issue is that you're passing an ETag to the request. ETags (and other E-headers) are used to detect modifications. They are most often used for GET requests and allow a server (or proxy) to skip retrieval of the data if there has been no changes on the E-headers since the last request. It is a caching mechanism.

    In your case you are passing an ETag probably from a previous GET. However by the time you make the request the object has been modified and therefore the tag doesn't match and it fails the call. This is a concurrency detection thing. Two solutions that I can see.

    Option 1 update to the new ETag and try again. In your Postman screenshot it doesn't actually look like you're passing the ETag header so that might be the problem by itself. Set the header to whatever you got from the GET request and try again.

    Option 2 is to not bother with the concurrency detection. Since you're just renaming a folder I would wager changes to it shouldn't matter. Therefore remove the If-Match header.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.