Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3630

How to copy file using Rest API and javascript in Sharepoint 2013 between site and subsite

$
0
0

I need to copy file between document libraries. Library A is located in one site and Library B is located in subsite. I know how to copy file between libraries on the same level but the problem is with copying between different level.

The code I use to copy file between libraries on the same level.

 $.ajax({     url : "http://xxx/PWA/_api/web/folders/GetByUrl('/PWA/CopyFromLibrary')/Files/getbyurl('Import.csv')/copyTo(strNewUrl = '/PWA/TargetLibrary/Import.csv',bOverWrite = true)",method: 'POST',    headers: {"Accept": "application/json; odata=verbose","X-RequestDigest":  $("#__REQUESTDIGEST").val()    },    success: function () {        alert("Success! Your file was copied properly");    },    error: function () {        alert("Problem with copying");    }    });

For different level I use just another target URL:

url : "http://xxx/PWA/_api/web/folders/GetByUrl('/PWA/CopyFromLibrary')/Files/getbyurl('Import.csv')/copyTo(strNewUrl = '/PWA/Subsite/TargetLibrary/Import.csv',bOverWrite = true)",

And it doesn't work.How to work around this problem?


Viewing all articles
Browse latest Browse all 3630

Trending Articles



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