Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Problem copying file using REST Api method CopyTo

$
0
0

Hi,

Its a pretty simple example i'm trying to execute. i have a folder which has a docx file and i want to call the restapi to copy it into the same folder with a new name. This is the url i'm using in my POST method call. My browser is already authenticated into sharepoint url so in theory i should be able to paste in the url and execute but its giving me an error. Here is my syntax:

https://mytestsite.sharepoint.com/sites/TestSite/_api/Web/GetFileByServerRelativeUrl('/sites/TestSite/account/_TEMPLATES/sampleFile.docx')
/copyTo('/sites/TestSite/account/_TEMPLATES/sampleFile_copy.docx',true)

When i run this it returns me a server 400 bad request.

Is there any easy way to debug this kind of stuff?

I tested this url by itself and it returns the file information correctly so i know the first part is working ok: https://mytestsite.sharepoint.com/sites/TestSite/_api/Web/GetFileByServerRelativeUrl('/sites/TestSite/account/_TEMPLATES/sampleFile.docx')

any help appreciated! thanks,

Paul


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>