0
votes

When I'm trying to download files from Sharepoint Online using REST, by calling _api/web/GetFileByServerRelativeUrl, sometimes, I'm getting error : The length of the URL for this request exceeds the configured maxUrlLength value.

So, as this is Sharepoint Online, there no way to change this configuration (the limit it self is also not clear, why 256 and not 1024 ??, or why to limit at all ??) So, I was trying to find a solution for this issue and found that I can call another REST method : /_api/web/GetFileById and provide unique id, which is working in 95% of cases, except some case where document library is SitePages or where the URL of the file is really big (even when I'm trying to download using GetFileById), the error here is 404 - not found.

So, web service do allow to access and download those files, BUT web service doesn't work with OAuth tokens (my customers requires OAuth).

Is there any other solution for this ? Or any chance to influence on the 256 chars url limit ?

Thanks

2

2 Answers

0
votes

There are certain software boundaries for SharePoint which includes the length of URL. You can find the complete details for URL path length restrictions in the below mentioned MSDN link (This is still applicable for SP2013)

https://technet.microsoft.com/en-in/library/ff919564(v=office.14).aspx

Coming back to your problem, have you tried using Javascript object model with sp.js or spservices ? You can find quick start helpers here.

https://msdn.microsoft.com/library/jj163201.aspx#BasicOps_FileTasks

0
votes

Don't know about why limit is 256 characters but for your other questions. You are right to prevent this "url lenght exceed error" you should use /GetFileById

https://site_url/_api/web/GetFileById('file_unique_id')

This api will give url length exceed error only if your "site_url" is very large either from having large name of sites or large site heirarchy depth in which case request will fail.

For this line in your question

"except some case where document library is SitePages"

This is not correct.This request works for all libraries.

For other help you can also refer https://sharepoint.stackexchange.com/questions/194576/url-request-length-limit-when-using-rest-apis