Unable to download more than 1GB file from SharePoint Personal site

Copper Contributor

Hi,

 

We are downloading files from SharePoint site using below API.

 

/_api/web/getFileByServerRelativeUrl('{0}')/$value

 

For download I am using the OpenRead method of WebClient object like client.OpenRead(webUrl). We are using modern authentication (bearer token) for authentication/authorization. For SharePoint Sites (e.g. https://vi***.sharepoint.com/sites/Tea3) it is working fine but for Personal Sites (e.g. https://vi***-my.sharepoint.com/personal/sai_vi***_onmicrosoft_com/Test/Forms/AllItems.aspx) getting Unauthorized error. Both are in same tenant with same ServicePrinciple account.

 

There is another API from CSOM file.OpenBinaryStream(). This is working for both SharePoint Sites and Personal Sites. But it has limitation of download up to 1GB of files only. More than 1GB is not supported with this API.

 

Can you please provide some solution so that I can use the WebClient API for both SharePoint Sites and Personal Sites?

 

Thanks and Regards,

Nitesh Kumar

2 Replies

Hi, @niteshas 

 

Can you please tell how you are using Bearer token for downloads? I am facing the same issue but my issue is with all the downloads irrespective of the site type. Can you please share how you are getting the Bearer Token?

Hi,

I think the scope while acquiring the toke is the problem here.

For Onedrive : https://<tenant>-my.sharepoint.com
For Sharepoint : https://<tenant>.sharepoint.com

By setting this above scope while getting the access_token, I am able to download files from both Sharepoint and Onedrive.

Hope this helps!