SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to copy a file located in user's personal folder (OneDrive Pro) using REST API. The resulting link seems to become too long and server returns 400 BadRequest: The length of the URL for this request exceeds the configured maxUrlLength value.

Url looks like this (HTTP verb is POST):

https://<company>-my.sharepoint.com/personal/<user>_<company>_onmicrosoft_com/_api/Web/GetFileByServerRelativeUrl('/personal/<user>_<company>_onmicrosoft_com/Documents/<Folder>/<Folder with guid-like name>/<filename>.pdf')/copyto(strnewurl='/personal/<user>_<company>_onmicrosoft_com/Documents/<Same folder>/<another guid-like name>/<same filename>.pdf',boverwrite=true)

Any help or advice on how to overcome this is highly appreciated.

share|improve this question

There is a maximum 256 character limit in SharePoint for REST URLs - reference:

https://msdn.microsoft.com/en-us/LIbrary/dn292556.aspx

However URL parameters are not included in the length-restriction, so can be used to get round this limit. Here is an example of using URL parameters to bypass this limit:

https://tenant-my.sharepoint.com/personal/user_account_tenant_onmicrosoft_com/_api/web/getfilebyserverrelativeurl(@v)/startupload(uploadId=guid'38acfb37-ccd5-4ac1-961d-090ce1ed9d6f')?@v='/personal/user_account_tenant_onmicrosoft_com/Documents/Test/7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso.001'

For a little more information you can see this post:

The length of the URL for this request exceeds the configured maxUrlLength value. REST API

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.