Graph API convert to other formats Error

Anonymous
2021-11-16T20:40:55.963+00:00

Using graph API, I have a .docx file stored on OneDrive, and I'm trying to convert the content to pdf following this page:

https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0&tabs=http
-> HTTP request -> GET /drive/items/{item-id}/content?format={format}

I obtain the document Assay.docx with the following item-id '01FA4YLQZRHSFJNXCIMBCLADQ6PMLTMWCJ'

149961-image.png

I am using 'GET /drive/items/01FA4YLQZRHSFJNXCIMBCLADQ6PMLTMWCJ/content?format=pdf'
But does not work. Responds with error 'itemNotFound'.
What is wrong with my request?

149926-image.png

I have also try with 'GET /me/drive/items/01FA4YLQZRHSFJNXCIMBCLADQ6PMLTMWCJ/content?format=pdf' :
149896-image.png

Microsoft Security Microsoft Graph
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 46,366 Reputation points
    2021-11-17T08:13:19.747+00:00

    Hi @Anonymous

    According to my test, this should be a problem with the Graph Explorer tool. You can switch to postman or other API tools to call the api.

    You need to grant the Files.ReadWrite.All application permission to your application in Azure AD, then use the client credential flow to get the token, and use the token to call https://graph.microsoft.com/v1.0/drives/{drive id}/items/{item id}/content?format=pdf endpoint. Then you will get the download URL, you just need to run it.

    150141-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.