0

Move SharePoint document library files to another site using REST API calls without using the SP.RequestExecutor object.

I just tried the Copy to and Move to methods, but these methods are working in SharePoint-hosted apps using the SP.RequestExecutor object, but normal Ajax call it is not working.

2

Firstly, there are no SharePoint REST APIs working specifically with the SP.RequestExecutor object. This Javascript object is used inside SharePoint-hosted apps to make web service calls (using REST APIs or JSOM) outside the SharePoint apps.

Secondly, from you question, I am not sure if you want to move files from:

  • a SharePoint-hosted app's web to the host web => If you want to move files from the app web to the host web using JS, there is no other way than using the SP.RequestExecutor object.

  • or from a standard SharePoint web to another standard web => In this case you can simply use AJAX (jQuery, SuperAgent, etc.) and the RESTful URL below. Be aware this works only when both webs are on the same domain. If you want to move files between two webs on different domains, try using a SharePoint 2013 workflow and the call web service action.


Here is the Uri structure for the SP.File.moveTo method: http://<sitecollection>/<site>/_api/web/folders/getbyurl(folderrelativeurl)/files/getbyurl(filerelativeurl)/moveTo(newUrl,flags) as taken from here.

  • Thank you. I succesfully implemented this endpoint: String.format("{0}/_api/Web/GetFileByServerRelativeUrl('{1}')/moveTo(newurl='{2}',flags={3})", webUrl, src, target, overwrite) src and target must include the filename. – Chris DS Oct 22 '18 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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