Hi previously I am using the following rest API to move the file or rename:
POST: {{baseUrl}}/{{siteName}}/_api/web/GetFileByServerRelativePath(decodedUrl=@v)/moveTo(newurl=@s,flags=0)?@v='oldpath'&@s='newpath'
This is working fine but causing an issue for the file name containing % or # value.
So to solve the issue I found on the following post.
So I have tried following rest API:
POST: {{baseUrl}}/{{siteName}}/_api/web/GetFileByServerRelativePath(decodedUrl=@v)/moveToUsingPath(newPath=@s,moveOperations=0)?@v='oldpath'&@s='newpath'
But it is throwing the following error:
{
"error": {
"code": "-1, Microsoft.Data.OData.ODataException",
"message": {
"lang": "en-US",
"value": "An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected."
}
}
}
if I tried to call rest API this way:
POST: {{baseUrl}}/{{siteName}}/_api/web/GetFileByServerRelativePath(decodedUrl='oldpath')/moveToUsingPath(newPath='newpath',moveOperations=0)
then it throws following error:
{
"error": {
"code": "-2147024891, System.UnauthorizedAccessException",
"message": {
"lang": "en-US",
"value": "Access denied."
}
}
}
Not sure what wrong I am doing.
@HarshitShah-3176 Do you have further questions about this thread? If you have any concerns, please feel free to reply.