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 ?