Sunday 27 November 2022

Issues viewing or sharing items upload to Sharepoint with msgraph in Python

I've been trying to upload files to a Sharepoint site using a python app.

I've successfully authenticated with my Azure app, using msgraph.

I've successfully (I think) uploaded files -

/drives/{drive_id}/root:/path/to/file:/content

returns

@microsoft.graph.downloadUrl: https://xxx.sharepoint.com/_layouts/15/download.aspx?UniqueId=xxx&Translate=false&tempauth=exxx&ApiVersion=2.0

createdDateTime: 2022-11-23T19:41:22Z
eTag: "{xxx},52"
id: xxx
lastModifiedDateTime: 2022-11-25T08:37:46Z
name: 2022-09.pdf
webUrl: https://xxx.sharepoint.com/NPSScheduling/All%20NPS%20Folders/Salesforce/2022-09.pdf
cTag: "c:{xxx},52"
size: 33097
createdBy: {'application': {'id': 'f333ebf7-899a-44aa-8697-6d5b71e8f722', 'displayName': 'Salesforce Chrono UPloads'}, 'user': {'displayName': 'SharePoint App'}}
lastModifiedBy: {'application': {'id': 'f333ebf7-899a-44aa-8697-6d5b71e8f722', 'displayName': 'Salesforce Chrono UPloads'}, 'user': {'displayName': 'SharePoint App'}}
parentReference: {'driveType': 'documentLibrary', 'driveId': 'b!xxx', 'id': 'xxx', 'path': '/drives/b!xxx/root:/All NPS Folders/Salesforce'}
file: {'mimeType': 'application/pdf', 'hashes': {'quickXorHash': 'nEGcsGbiYw5Q1OZfcBOg+2pbGts='}}
fileSystemInfo: {'createdDateTime': '2022-11-23T19:41:22Z', 'lastModifiedDateTime': '2022-11-25T08:37:46Z'}
shared: {'scope': 'users'}

However, when I try to view files in my Sharepoint folder, I don't see them. I am able to navigate to the webUrl, but get 'Could not load pdf'.

I tried creating a share link, but keep getting

item not found

no matter which format I try for the endpoint:

/sites/<site_id>/drive/items/<item_id>/createLink
/sites/<site_id>/drives/<drive_id>/items/<item_id>/createLink
/sites/<site_id>/path/to/file/createLink
/drives/<drive_id>/root:/path/to/file/createLink

and other variants on the same theme.

Any ideas?



from Issues viewing or sharing items upload to Sharepoint with msgraph in Python

No comments:

Post a Comment