0

I plan to design a workflow that move a document from main site to a subsite. But I found out that REST API moveTo/copyTo method only for within a same site.

Anyone have REST API solution ? Thank you.

FYI: I using Sharepoint designer 2013.

0

Indeed, you only can copy/move files between libraries at the same level. A walk around could by using the endpoint "/openbinarystream" this will retrieve... well a little obvius what this will return. When you get the binarystrem, using "RequestExecutor" you could use a call like this

$.getScript(_spPageContextInfo.webServerRelativeUrl + "/_layouts/15/SP.RequestExecutor.js", function () {
    var createitem = new SP.RequestExecutor(_spPageContextInfo.webServerRelativeUrl);
    createitem.executeAsync({
        url: _spPageContextInfo.webServerRelativeUrl + "/_api/web/lists/GetByTitle('list_template')/RootFolder/Files/add(FileName='file_name.docx', overwrite='false'))",
        method: "POST",
        binaryStringRequestBody: true,
        body: binary, //<-- your binary
        success: fsucc,
        error: ferr,
        state: "Insert"
    });
    function fsucc(data) {
        console.log(data + ' uploaded successfully');
        deferred.resolve(data);
    }
    function ferr(data) {
        console.log(fileName + "not uploaded error");
        deferred.reject(data);
    }
});

I hope it can help you

2
  • Thank for reply my question. But I just using the sharepoint designer 2013, it does not have coding. – vicky Mar 17 '17 at 3:45
  • this is javascript, not C# or servser side code. – Marco Mar 17 '17 at 12:18

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.