How to download a file from Sharepoint with python

Viewed 1429

I need to download a file from sharepoint using user credentials (rather that client credentials).

I've tried this:

from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.files.file import File

root_url = "https://company-my.sharepoint.com"
full_url = "https://company-my.sharepoint.com/personal/Documents/AB.csv"

ctx = ClientContext(root_url)
ctx.with_user_credentials(<my_email>,
                          <my_password)

response = File.open_binary(ctx, full_url)
print(response.content)

The response I am getting is

*b'{"error":{"code":"-2147024809, System.ArgumentException","message":{"lang":"en-US","value":"serverRelativePath\\r\\nParameter
name: Specified value is not supported for the serverRelativePath
parameter."}}}'*
0 Answers
Related