I am unable to rename the folder inside the document library using the REST api provided by SharePoint 2013. Here is the code I use below.
string digest = String.Empty; using (var response = await connector.HttpClient.PostAsync("_api/contextinfo", null, token)) { response.EnsureSuccessStatusCode(); var obj = await response.ReadObject("d"); digest = obj["GetContextWebInformation"].Value<string>("FormDigestValue"); } using (var request = new HttpRequestMessage(HttpMethod.Post, String.Format("/_api/Web/GetFolderByServerRelativeUrl('{0}')", operation.Path.FullName))) { request.Headers.Add("X-HTTP-Method", "MERGE"); request.Headers.Add("IF-MATCH", "*"); request.Headers.Add("X-RequestDigest", digest);
In Fiddler, here is the request:
POST http://2013.blah.com/_api/Web/GetFolderByServerRelativeUrl('/Shared%20Documents/Test') HTTP/1.1 X-HTTP-Method: MERGE IF-MATCH: * X-RequestDigest: 0xA7C057B3AECE805B7313909570F64B8EACD7A677014B8EBE7F75CC5A7C081F87973D94E7CC22346964ECAB1FE3C6B326DA3B67DF7A646FE6F47E9B1E686C3985,11 Apr 2013 15:13:05 -0000 Accept: application/json; odata=verbose Content-Type: application/json; odata=verbose Host: 2013.skysync.com Content-Length: 50 Expect: 100-continue {"__metadata":{"type":"SP.Folder"},"Name":"Test2"}
And then the answer:
HTTP/1.1 204 No Content Cache-Control: private, max-age=0 Expires: Wed, 27 Mar 2013 15:13:15 GMT Last-Modified: Thu, 11 Apr 2013 15:13:15 GMT Server: Microsoft-IIS/8.0 X-SharePointHealthScore: 0 SPClientServiceRequestDuration: 15 X-AspNet-Version: 4.0.30319 SPRequestGuid: 53bd109c-43bb-2064-4a1b-82298b670ece request-id: 53bd109c-43bb-2064-4a1b-82298b670ece X-RequestDigest: 0x9CDB4F31CC5F3877C4383657C12BEC6CFF10FC28AB6A0BB2D9D38B4279187CBD1450359BDFF07F0E63FF550BFF96C46E0476FB895CDA104348AC066D86246BC6,11 Apr 2013 15:13:15 -0000 X-FRAME-OPTIONS: SAMEORIGIN X-Powered-By: ASP.NET MicrosoftSharePointTeamServices: 15.0.0.4420 X-Content-Type-Options: nosniff X-MS-InvokeApp: 1; RequireReadOnly Date: Thu, 11 Apr 2013 15:13:15 GMT
Everything looks fine until I get back to SharePoint, and the test folder still matches the name. I follow the recommendations here , and I have seen other very similar examples. I can rename it through the interface without any problems.
Thanks in advance for your help!
Troyc source share