Jan 20 2021 04:26 AM
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
May 02 2022 12:06 AM
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?
May 04 2022 12:09 AM