Hi,
I'm trying to add a file from a Rootsite to a SubSite using REST API.
There some code:
$.ajax ( {
url : _spPageContextInfo.siteAbsoluteUrl + "/_api/web/getFileByServerRelativeUrl('" + selected + "')/$value",
type : "GET",
headers : { "Accept" : "application/json;odata=verbose" },
binaryStringResponseBody : true
} )
.done ( function ( data ) {
if ( data === null ) {
console.error ( "The file wasn't downloaded" );
return;
}
$.ajax ( {
url : "https://dev.sharepoint.com/sites/myrootsite/_api/web/getFolderByServerRelativeUrl('/sites/myrootsite/mysubsite/Lists/uploadeddocs')/Files/add(url='testFileUploaded.docx')",
type : "POST",
data : sdata,
headers : {"Accept" : "application/json;odata=verbose","X-RequestDigest" : $ ( "#__REQUESTDIGEST" ).val ( )
}
} )
.done ( function ( ) { console.log ( "fuck yeah" ); } )
.fail ( function ( ) { console.error ( "as usual" ); } );
} );but I always get the "File not found" error.
If I using the same code to create the file in the current rootsite it works.
Some ideas?
Cheers