I am trying to read a file from sharepoint using the office 365 package. My code looks like this:
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.file import File
app_settings = {
'url': 'https://xxxx.sharepoint.com/sites/mysite/',
'client_id': 'id',
'client_secret': 'secret'}
context_auth = AuthenticationContext(url=app_settings['url'])
context_auth.acquire_token_for_app(client_id=app_settings['client_id'],
client_secret=app_settings['client_secret'])
ctx = ClientContext(app_settings['url'], context_auth)
File.open_binary(ctx, '/sites/mysite/Documents/Dictionary.csv')
I've tried several variations of the server relative url and get the error every time:
MissingSchema: Invalid URL "<bound method ClientContext.service_root_url of
<office365.sharepoint.client_context.ClientContext object at
0x00019D2CCED68>>web/getfilebyserverrelativeurl
('/sites/mysite/Documents/Dictionary.csv')/\\$value": No schema supplied.
Perhaps you meant http://<bound method ClientContext.service_root_url of
<office365.sharepoint.client_context.ClientContext object at
0x00019D2CCED68>>web/getfilebyserverrelativeurl('/sites/mysite/Documents/Dictionary.csv')/\$value?
Is there a simple way to read and download files from sharepoint online using the office365 library?