I try to convert a selected Word document (docx) in a SharePoint-Online list with the Graph Api (MSGraphClientV3) into an Pdf document. I can successfully upload the seleted document to my One-Drive
const apiUrl: string = `/me/drive/root:/${file.name}:/content`;
const resp = await this.client.api(apiUrl).put(file);
But when I try to convert the document with
const options = {
headers: {
'Content-Type': 'application/pdf',
},
};
const blob = await this.client
.api(`/me/drive/items/${fileID}/content?format=pdf`)
.headers(options.headers)
.responseType('blob')
.get();
I always get: "Resource not found"
The fileID is correct as I can download the file with:
const apiUrl = `/me/drive/items/${fileID}`;
this.client.api(apiUrl).get()
Api permissions of my package-solution.json:
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "Files.ReadWrite"
}
]
Permission request is approved through SharePoint-Admin Site. The Api call should respond with a 302 Found response redirecting to a pre-authenticated download URL for the converted file.
I do not want to use Flow or an Azure function to do the conversion. Spec is here.
What am I missing?
Thanks, Ronny