SOLVED

SharePoint REST API moveTo URL limitation

%3CLINGO-SUB%20id%3D%22lingo-sub-15815%22%20slang%3D%22en-US%22%3ESharePoint%20REST%20API%20moveTo%20URL%20limitation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-15815%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20community%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20using%20SharePoint%20REST%20API%20in%20SharePoint%20(Online)%202013%20Workflow%20to%20move%20documents%20b%2Fw%20different%20libraries.%20It%20was%20working%20fine%20for%20files%20with%20%3CSTRONG%3Esmall%20names%3C%2FSTRONG%3E%20but%20it%20failed%20for%20documents%20with%20very%20large%20names.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20REST%20API%20we%20have%20to%20pass%20server%20relative%20URL%20in%20the%20moveTo%20method%20so%20it%20fails%20if%20my%20destination%20library%20structure%20contains%20nested%20folders%20and%20server%20relative%20URL%20becomes%20very%20lengthy.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1)%20Is%20there%20a%20work%20around%20for%20this%20URL%20limitation%20(260%20characters)%3C%2FP%3E%3CP%3E1)%20Can%20i%20use%20%22GetFileByID%22%20or%20%22GetFolderByID%22%20to%20move%20documents%20using%20REST%20API%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F60%22%20target%3D%22_blank%22%3E%40Juan%20Carlos%20Gonz%C3%A1lez%20Mart%C3%ADn%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHelp%20needed!%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-255203%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20REST%20API%20moveTo%20URL%20limitation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-255203%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%20I%20know%20its%20been%20a%20while%20but%20could%20you%20elaborate%20a%20little%20more%20on%20the%20resolution.%26nbsp%3B%20I%20have%20run%20into%20the%20same%20issue%20using%20SharePoint%202013%20designer%20workflow.%26nbsp%3B%20A%20screen%20shot%20would%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-122532%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20REST%20API%20moveTo%20URL%20limitation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-122532%22%20slang%3D%22en-US%22%3EPerfect.%20Tony%20Hignett's%20solution%20works%20for%20files%20with%20Large%20names.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-56560%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20REST%20API%20moveTo%20URL%20limitation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-56560%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Brent%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20put%20the%20newUrl%20variable%20in%20a%20Dictionary.%3C%2FP%3E%3CP%3EThe%20assign%20the%20Dictionary%20as%20the%20parmeters%20of%20the%20Call%20HTTP%20web%20service%26nbsp%3Baction.%3C%2FP%3E%3CP%3EThe%20POST%20method%20will%20include%20it%20as%20payload.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3Ethen%20Build%20%7B...%7D%20Dictionary%20(Output%20to%20Variable%3A%20parameters)%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20346px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F12331i24135B5D55A10F26%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Capture.JPG%22%20title%3D%22Capture.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20pass%20the%20Dictionary%20to%20the%20Call%20HTTP%20web%20Service%20action...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EThe%20Call%20%5BMy%20Site%2FMyList%2FMyItem%20etc.%5D%2Ffile%2FMoveTo()%20HTTP%20web%20service%20with%20Variable%3Aparameters%20(Response%20Content%20to.....%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps%2C%3C%2FP%3E%3CP%3ETony%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-49277%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20REST%20API%20moveTo%20URL%20limitation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-49277%22%20slang%3D%22en-US%22%3E%3CP%3EResurrecting%20this%20instead%20of%20posting%20a%20new%20one.%20%26nbsp%3BI've%20just%20come%20upon%20this%20same%20issue.%20%26nbsp%3BIs%20there%20no%20way%20to%20work%20around%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20a%20url%20for%20a%20POST%20that%20is%20296%20characters%20long%20(and%20SUCCEEDS)%20(259%20char%20excluding%20the%20tenant)%20-%20replaced%20with%20b's%2C%20x's%2C%20and%20y's%20to%20protect%20the%20innocent%2C%20but%20the%20following%20depicts%20exact%20length%3C%2FP%3E%3CPRE%3Ehttps%3A%2F%2Fbbbbbbbbbbbbbb.sharepoint.com%2Fsites%2Fcustomer%2Fplan%2F_api%2Fweb%2Flists%2Fgetbyid('34b6672e-531e-443e-86a8-eeb17eb9259f')%2Fitems(172)%2Ffile%2Fmoveto(newurl%3D'%2Fsites%2Fxxxxxxxx%2Fyyyy%2F151%2Fbbb%20bbbbb%20bbbbbbb%20bb%20(bb)%20bbbb%2Fbb%20bbbbbbb%20bbb%20bbbbbbbb%20Reports%2FService%20Reports%202015%2F2015%20Sample%20Doc%20Five.docx'%2Cflags%3D1)%3C%2FPRE%3E%3CP%3EThis%20is%20a%20url%20for%20a%20POST%20that%20is%20298%20characters%20long%20(and%20FAILS)%20(261%20char%20excluding%20the%20tenant)%3C%2FP%3E%3CPRE%3Ehttps%3A%2F%2Fbbbbbbbbbbbbbb.sharepoint.com%2Fsites%2Fcustomer%2Fplan%2F_api%2Fweb%2Flists%2Fgetbyid('34b6672e-531e-443e-86a8-eeb17eb9259f')%2Fitems(172)%2Ffile%2Fmoveto(newurl%3D'%2Fsites%2Fcustomer%2Fplan%2F151%2Fbbb%20bbbbb%20bbbbbbb%20bb%20(bb)%20bbbb%2Fbb%20bbbbbbb%20bbb%20bbbbbbbb%20Reports%2FService%20Reports%202015%2F201501%20Sample%20Doc%20Five.docx'%2Cflags%3D1)%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20is%20no%20way%20at%20all%20to%20perform%20this%20file%20move%20using%20REST%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-15949%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20REST%20API%20moveTo%20URL%20limitation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-15949%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Bilal%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20i%20am%20correct%20you%20can%20get%20the%20docid%20and%20use%20that%20one.%20Only%20on%20the%20move%20you%20have%20to%20get%20the%20stream%20to%20put%20it%20in%20the%20new%20library.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ehope%20it%20helps.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPaul%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hello community,

 

I am using SharePoint REST API in SharePoint (Online) 2013 Workflow to move documents b/w different libraries. It was working fine for files with small names but it failed for documents with very large names. 

 

For REST API we have to pass server relative URL in the moveTo method so it fails if my destination library structure contains nested folders and server relative URL becomes very lengthy.

 

1) Is there a work around for this URL limitation (260 characters)

1) Can i use "GetFileByID" or "GetFolderByID" to move documents using REST API?

 

@Juan Carlos González Martín

 

Help needed! 

 

5 Replies
Highlighted

Hi Bilal,

 

If i am correct you can get the docid and use that one. Only on the move you have to get the stream to put it in the new library.

 

hope it helps.

 

Paul

Highlighted

Resurrecting this instead of posting a new one.  I've just come upon this same issue.  Is there no way to work around this?

 

This is a url for a POST that is 296 characters long (and SUCCEEDS) (259 char excluding the tenant) - replaced with b's, x's, and y's to protect the innocent, but the following depicts exact length

https://bbbbbbbbbbbbbb.sharepoint.com/sites/customer/plan/_api/web/lists/getbyid('34b6672e-531e-443e-86a8-eeb17eb9259f')/items(172)/file/moveto(newurl='/sites/xxxxxxxx/yyyy/151/bbb bbbbb bbbbbbb bb (bb) bbbb/bb bbbbbbb bbb bbbbbbbb Reports/Service Reports 2015/2015 Sample Doc Five.docx',flags=1)

This is a url for a POST that is 298 characters long (and FAILS) (261 char excluding the tenant)

https://bbbbbbbbbbbbbb.sharepoint.com/sites/customer/plan/_api/web/lists/getbyid('34b6672e-531e-443e-86a8-eeb17eb9259f')/items(172)/file/moveto(newurl='/sites/customer/plan/151/bbb bbbbb bbbbbbb bb (bb) bbbb/bb bbbbbbb bbb bbbbbbbb Reports/Service Reports 2015/201501 Sample Doc Five.docx',flags=1)

 

There is no way at all to perform this file move using REST?

Highlighted
Solution

Hi Brent

 

You can put the newUrl variable in a Dictionary.

The assign the Dictionary as the parmeters of the Call HTTP web service action.

The POST method will include it as payload.

 

then Build {...} Dictionary (Output to Variable: parameters)

 

Capture.JPG

 

The pass the Dictionary to the Call HTTP web Service action...

 

The Call [My Site/MyList/MyItem etc.]/file/MoveTo() HTTP web service with Variable:parameters (Response Content to.....

 

Hope this helps,

Tony

Highlighted
Perfect. Tony Hignett's solution works for files with Large names.
Highlighted

Hi, I know its been a while but could you elaborate a little more on the resolution.  I have run into the same issue using SharePoint 2013 designer workflow.  A screen shot would help.

 

Thanks