Graph API convert to other formats Error

Laura Serrano López 1 Reputation point
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 Graph Files API
Microsoft Graph Files API
A Microsoft API to create an app that connects with files across OneDrive, OneDrive for Business, and SharePoint document libraries.
305 questions
Microsoft Graph SDK
Microsoft Graph SDK
A Microsoft software developer kit designed to simplify building high-quality, efficient, and resilient applications that access Microsoft Graph.
738 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Carl Zhao_MSFT 18,296 Reputation points Microsoft Employee
    2021-11-17T08:13:19.747+00:00

    Hi @Laura Serrano López

    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.