1

I use the MS Graph API to upload local files in a SharePoint.

It works well with Word or Text files. I can upload them in the SharePoint

I can also upload Pdf files but i cannot open the Pdf correctly in SharePoint: "No preview is available for this file". Of course, it opens normally if i upload manually the Pdf in the SharePoint.

Based on what i read on internet, it looks to be an encoding issue but i cannot make it work. How to upload pdf file to Sharepoint site using MicrosoftGraph

I use this request:

PUT ​/sites​/{site-id}​/drive​/items​/{parent-id}:​/{filename}:​/content

Ex: Invoke-WebRequest -Method PUT -Uri "https: XXX sharepoint-online/v1/sites/siteid/drive/items/parentid:/PDFfile:/content" -Headers @{'APIKEY'='XXX';'Content-Type'='multipart/form-data';'Accept'='application/json';'Authorization'="Bearer accesstoken"} -InFile $pathtopdffile

Any help/advise please ?

Xav Dou
  • 83
  • 1
  • 1
  • 5
  • @KJ, thanks for the quick return. I also tried with content-type", "application/pdf" but i get the same error. The pdf file cannot be previewed. I also removed the ;'Accept'='application/json' but i get same issue. – Xav Dou Dec 03 '21 at 15:27
  • Did you manage to solve this issue? I am facing the same problem – Jeroen Vermunt Jun 13 '22 at 09:51

0 Answers0