SharePoint Designer Workflow Move Document with Rest API

One of the things that are missing in SharePoint Designer is an action to Move a document from one location to another. There are a lot of awesome articles out there to get started with SPD and Rest API’s. I personally had a lot of Fabian Williams his posts. http://fabiangwilliams.wordpress.com/tag/rest/ .. Paolo Prialorsi has a WSP with a custom move action: http://www.sharepoint-reference.com/Blog/Lists/Posts/Post.aspx?ID=37

I wanted it to do with REST to check out the possibilities. Workflows run under the credentials & user permissions of the one who initiates the request. So if we want to run the the workflow using different rights we need to use a App Step. Read more on: http://msdn.microsoft.com/en-us/library/jj822159.aspx

In my case I need to call {currentWebUri}/_api/web/lists/GetById(guid'{ListId}’)/Items({sourceItemID})/File/MoveTo(newUrl='{targetFolder}’,flags=’1′) .

When I translate this to SPD I’ll get:

00

A REST API Call has also a Request Header. This we need to fill up with the necessary parameters. To see what your parameters need to be, use fiddler to simulate your Rest API Call. I urge you to check Fabian’s blog for detailed information about how to do this. In my case I need one parameter Accept. If I want to provide this to my Rest API Call, I need to add it to a Dictionary.

01

When we combine these things together we’ve got:

02

If you move the file/item that this workflow was running on outside it’s document library/list, the workflow will become disassociated. The workflow will keep on being in a running state but it will have no document/item that it can attach to.

2 thoughts on “SharePoint Designer Workflow Move Document with Rest API

Leave a Reply