I wrote a java code to update(rename) a folder in SharePoint based on the reference in the link ( https://msdn.microsoft.com/en-us/library/office/dn292553.aspx)
Example, We are updating(renaming) a folder in SharePoint from 'Movies' to 'News'
The code get executed without Exception, but the folder didn't get updated in SharePoint.
The response returns with HTTP status code of 204(No Content)
String url = "https://siteurl/_api/web/GetFolderByServerRelativeUrl('/Shared%20Documents/Movies')";
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(url);
post.setHeader("X-RequestForceAuthentication", "true");
post.setHeader("Content-Type", "application/json;odata=verbose");
post.setHeader("Accept", "application/json;odata=verbose");
post.setHeader("X-HTTP-Method", "MERGE");
post.setHeader("IF-MATCH", "*");
StringEntity stringEntity = new StringEntity("{ '__metadata': { 'type': 'SP.Folder' }, 'Name': 'News'}");
post.setEntity(stringEntity);
post.setHeader("X-RequestDigest","xxxxxxxxxxxxxxxxxxxxxxx");
post.setHeader("Cookie",
"rtFa=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
HttpResponse response = client.execute(post);
System.out.println("Response Code : " + response.getStatusLine().getStatusCode());
if (response.getEntity() != null) {
BufferedReader rd = new BufferedReader(
new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
System.out.println("RESULT = " + result.toString());
}
Any help would be appreciated.