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.
Just in case if anyone else will face this problem and you will have unique id in your SP.
If first part, which is
GetFileByServerRelativeUrl('/personal/<user>_<company>_onmicrosoft_com/Documents/<Folder>/<Folder with guid-like name>/<filename>.pdf')
will be replaced with GetFileById(uniqueId)
the limitation would be satisfied and copy will succeed.