Copy list item attachments to a document library in SharePoint 2013 designer workflow
-
18-02-2021 - |
سؤال
Is it possible to copy the attachments of a list item to a Document library using 2013 designer workflows?
I am able to get the server relative URL of the attachments in the workflow, but I am not sure if there is a way to copy using the server relative URL
Is there a method like copyto that exists for copying files from library to a different library?
المحلول
I converted the below request as a http request and called it from Designer workflow and it is copying files as expected
$.ajax({
url:"https://tenant.sharepoint.com/sites/sitename/_api/web/GetFileByServerRelativeUrl('/sites/sitename/Lists/ListName/Attachments/11/sample.jpg')/copyTo(strNewUrl='DestinationRelativeURL',bOverWrite=true)",
headers:{"accept":"application/json;odata=verbose","content-type":"application/json;odata=verbose","X-RequestDigest": jQuery("#__REQUESTDIGEST").val()},
method: "POST",
success:function(data){
console.log(data);
},
error:function(xhr){
console.log(xhr);
}
})
Before making this http request, we need to make one http request(_api/contextinfo)
to get the RequestDigest
لا تنتمي إلى sharepoint.stackexchange