Vadim Tabakman

Nintex Workflow for Office 365 - Copy Attachments to Document Library

Copying attachments from a List Item to a Document Library in Office 365 is not straightforward, until you actually get it working.  Then it totally makes sense.

I went through a bunch of blog posts and suggestions from people, and eventually, came across REST calls that people are making.  Now I'm not a guru with REST calls, so a lot of this is scavenged from places.  But it works and I LOVE IT!!

Let's break this up into the individual bits.

Get Attachment URLs

This Call HTTP Web Service is performing a GET here and making the following call : ‎‏{Workflow Context:Current site URL}‌_api/web/lists/GetByTitle('‎‏{Workflow Context:List Name}‌')/Items(‎‏{Current Item:ID}‌)/AttachmentFiles

That's a fairly generic call, and I don't believe you need to make any changes here.  We are getting the current list, then the current item and finally, the AttachmentFiles.  This will result in a Dictionary.

Loop through each Attachment

There are a few actions that I'm not going to go into here, which is Count the number of attachments in the response, create an index(counter) and Loop through each attachment.

Then we parse the data in that dictionary.

This gets the Server Relative URL from the response for the file we are working on.

This action gets the Filename of the attachment we are working on.

Copy the Attachment to a Document Library

The final part is the a REST call (POST) to copy the attachment to the destination library.

This is what the URL looks like : ‎‏{Workflow Context:Current site URL}‌/_api/web/getfilebyserverrelativeurl('‎‏{Variable:AttachmentURL}‌')/copyto(strnewurl='/Evangelism/My%20Pictures/‎‏{Variable:AttachmentFileName}‌',boverwrite=true)

Notice that this URL you will need to modify, because in the 2nd half of it, I've had to hard code the /site/doclib  (/Evangelism/My%20Pictures).  You'll need to tweak this to point to your destination library.  Also notice the last parameter, which is boverwrite and I have it set to true.  This means if a file with that name exists, it will overwrite it.



Posted by Vadim Tabakman Thursday, January 5, 2017 2:55:00 PM Categories: Attachments Call Web Service Loop Nintex Nintex Workflow Nintex Workflow for Office 365 REST
Copyright Vadim Tabakman
Rate this Content 0 Votes


Wednesday, June 21, 2017 9:53:05 AM

re: Nintex Workflow for Office 365 - Copy Attachments to Document Library

This looks great ... and exactly what I'm looking for. However, when I try to download the attachments (Move and Attachments to DocLib Workflow) they are nwf documents and not recognized on our equipment. Would it be possible to send these to me via another method (pdf, word, etc.)?

Thank you.

Wednesday, June 21, 2017 11:01:09 AM

re: Nintex Workflow for Office 365 - Copy Attachments to Document Library

Hi Marnita,


it's a NWP file.  Should I zip it up and email it to you?


Thursday, October 12, 2017 8:29:02 AM

re: Nintex Workflow for Office 365 - Copy Attachments to Document Library


Many thanks for post. You saved me a lot of time.

I was little bit confused with workflow file name and expected result "move" instead "copy".

For move result should be other url

{Workflow Context:Current site URL}‌/_api/web/getfilebyserverrelativeurl('‎‏{Variable:AttachmentURL}‌')/moveto(newurl='/Evangelism/My%20Pictures/‎‏{Variable:AttachmentFileName}‌',flags=1)

You must sign in to this site to post comments.
Already Registered?
Sign In
Not Yet Registered?



  • Entries (253)
  • Comments (1738)