2

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.

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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