0

When I'm trying to rename sub floder, I'm getting issue mention below:

"{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"Invalid request."}}}"

Code:

var itemPayload = {}; itemPayload['Title'] = "new name"; itemPayload['FileLeafRef'] = "new name"; var headers = {}; headers["Accept"] = "application/json;odata=verbose"; headers["X-RequestDigest"] = $("#__REQUESTDIGEST").val(); $.ajax({ type: "POST", url: spURL + "/_api/web/GetFolderByServerRelativeUrl('/a/b/c')/ListItemAllFields", data: JSON.stringify(itemPayload), headers: headers, contentType: "application/json;odata=verbose", success: function(response) { alert(response); }, error: function(error) { debugger; } }); 

Thanks for the help!

1

1 Answer 1

0

answer:

ExecuteOrDelayUntilScriptLoaded(UpdateListItem, "sp.js"); function UpdateListItem(){ var clientContext; var oWebsite; var oList; clientContext = new SP.ClientContext.get_current(); oWebsite = clientContext.get_web(); oList = oWebsite.get_lists().getByTitle("DocumentLibrary"); oListItem = oList.getItemById(1); this.oListItem.set_item("FileLeafRef", "Folder Name"); this.oListItem.update(); clientContext.load(this.oListItem); clientContext.executeQueryAsync(onSuccess, onFailure); } function onSuccess() { alert('Update succeeded.'); } function onFailure(sender, args) { alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); } 

Thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.