I have a folder in sharepoint. I wanted to move a file from one folder to another.

As per documentation, my trial was like below.

 headers = {"Authorization" : "Barer" + Token, 
            'Accept': 'application/json;odata=nometadata',
            'Content-Type': 'application/json;odata=verbose',
            'X-HTTP-Method': "POST",
            'X-RequestForceAuthentication': 'true'

url = "https://sharepointDomain/sites/<app_name>/_api/web/getFileByServerRelativeUrl('/sites/SourceFoldername/test.xlsx')/moveto(newurl=/sites/DestinationFolderName/Test.xlsx',flags=1)?@target=sharepointDomain"

response = request.post(url, headers = headers)

And the response I get is

The HTTP method 'GET' cannot be used to access the resource 'moveto'. The operation type of the resource is specified as 'Default' 

Thanks in advance.

1 Answer 1


The url should be like:


My test code:

function MoveFile(){
        var oUrl =  _spPageContextInfo.webAbsoluteUrl +"/_api/web/getfilebyserverrelativeurl('/doc2/doc.docx')/moveto(newurl='/doc1/doc.docx',flags=1)";
            url: oUrl,
            type: "POST",
            headers: {
                "Accept": "application/json; odata=verbose",
                "X-RequestDigest":  $("#__REQUESTDIGEST").val()
            success: function(data){
            error: function(data){

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.