Unable to Convert PPTX to PDF Using Microsoft Graph API - 400 Invalid Request Error

石川 敦己 45 Reputation points
2024-05-27T10:26:14.56+00:00

I am attempting to convert a PPTX file to a PDF using the Microsoft Graph API and encountering a 400 error. Here are the details:

{
  "error": {
    "code": "invalidRequest",
    "message": "Invalid request"
  }
}
  • The scope I am using is Files.Read.
  • The only header included in the request is Authorization: Bearer ${accessToken}.
  • When I send a request to https://graph.microsoft.com/v1.0/me/drive/items/{item-id}/content, I receive what appears to be the raw file data without any issues.
  • I have tried adding headers such as if-none-match with an eTag and using a PPTX file with only a few test characters, but I consistently receive a 400 Invalid Request error.

Could you please provide guidance on how to resolve this issue and successfully convert a PPTX file to a PDF using the Microsoft Graph API?

Thank you for your assistance.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,445 questions
0 comments No comments
{count} votes

Accepted answer
  1. Hitesh Pachipulusu - MSFT 475 Reputation points Microsoft Vendor
    2024-05-27T16:34:59.83+00:00

    Hello,Thank you for contacting Microsoft Support.

    I have successfully implemented the same Graph API call in Postman and received the response. However, it is not possible to use Microsoft Graph Explorer to download files.

    convertpdf

    The 400 Bad Request error typically indicates that something is wrong with the syntax of the request. Here are a few steps you can take to troubleshoot and resolve the issue:

    1. Check the File Format: Ensure that the file you’re trying to convert is indeed a .pptx file. The Graph API supports conversion from .pptx to .pdf.
    2. Verify the Item ID: Make sure that the {drive-id} & {item-id} you’re using in the request URL is correct and that it corresponds to a PPTX file in your OneDrive.
    3. Correct Scopes: The Files.Read scope should be sufficient for reading the file content, but you might also need the Files.Read.All or Sites.Read.All scopes if you’re accessing shared files or sites.
    4. Authorization Token: Confirm that the access token is valid and has not expired. It should have the necessary permissions to access the file.

    Please refer https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0&tabs=http.

    If you continue to experience the issue, I recommend raising a support case with Microsoft Graph. A Support Engineer will then be able to investigate the issue further and provide you with assistance. You can raise support ticket from New support request - Microsoft Entra admin center or https://admin.microsoft.com/#/support/requests.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful