Copy attachment from a list item to another list item using SharePoint REST API

  • 25 October 2019
  • 0 replies
  • 88 views

Badge

I am having trouble using SharePoint's REST API to copy attachments from one list item to another list item in a different site collection. Can someone please help?

 

Using REST, I am able to generate the attachment, but it's contents are blank

 

I used a Web Request to get the contents of the attachment:

https://<site>/_api/web/getfilebyserverrelativeurl('<relativeURL>')/$value?binaryStringResponseBody=true

 

5076i55B7869B6B570ADB.png

 

I then used another Web Request to add the attachment to desired list item:

https://<site>/_api/web/lists/GetByTitle('')/items({WorkflowVariable:itemID})/AttachmentFiles/add(FileName='<filename>')

 

5074iD162041C3FD7DA41.png

 

However, the attachment is blank :(

 

I know there have been previous topics that have touched on how to do this, but I am just not able to piece together the bits to get it working.

 

Some of the posts and blogs I have been looking at include:

 

Fetching an Adding an attachment using Call Web Service action

https://community.nintex.com/t5/Nintex-for-SharePoint/Fetching-an-Adding-an-attachment-using-Call-Web-Service-action/td-p/3099

 

How to execute a SP2013 REST API request with Nintex Workflow

https://community.nintex.com/t5/Community-Blogs/How-to-execute-a-SP2013-REST-API-request-with-Nintex-Workflow/ba-p/81942

 

Thanks in advance :)


0 replies

Be the first to reply!

Reply