Shaunak Patel
Shaunak Patel

Reputation: 1671

Not able to convert .docx file to pdf using microsoft graph api

For my project need, I need to convert MS format documents in to pdf. I started exploring microsoft graph API. For easiness I started with graph explorer(using my corporate and personal login) on https://developer.microsoft.com/en-us/graph/graph-explorer.

I have added sample document in drive and using https://graph.microsoft.com/v1.0/me/drive/root/children, I got itemId of my file.

Now, I am trying to convert it into pdf using https://graph.microsoft.com/v1.0/me/drive/items/{itemId}/content?format=pdf. But I am always getting response as Failure - Status Code 0

Anyone has an idea how to fix this issue?

Here is an attached screen shot of microsoft graph explorer

enter image description here

Note: I found similar problem here but it is not solved

Upvotes: 0

Views: 1709

Answers (1)

Keen Jin
Keen Jin

Reputation: 1138

According to your description, I assume you want to convert .docx file to pdf using Microsoft graph API.

Based on my test, we can use https://graph.microsoft.com/v1.0/me/drive/items/{itemId}/content?format=pdf.

It will return a failure response when run it in graph explore. However, when we use the develop control panel, we can get this request and response.

Location properties are in the response headers. It is the address of the converted file.

We can use this URI to review or download the document that converted.

The request URL:

https://graph.microsoft.com/v1.0/me/drive/items/{itemId}/content?format=pdf

The response may like this:

enter image description here

Upvotes: 1

Related Questions