OfficeConversion_Fatal Error trying to convert pptx to pdf with more than 100 pages via Graph API

Nemyrovska, Maryna 40 Reputation points
2024-08-30T11:13:53.64+00:00

Dear Sir or Madam,

There is an error appearing from converting pptx to pdf from o365 office via Graph API. We use a sharepoint from which we can read data via an o365 app registration. The error appears with documents starting form > 100 pages. The document which failed had 170 slides of the size 19,4 MB. Setting up a timeout for the request did not solve the problem. Please, see the attached code and the error message:

 

```

url = f"https://graph.microsoft.com/v1.0/sites/{sharepoint_id}/drive/items/{document_id}/content?format=pdf"

headers = {'Authorization': 'Bearer ' + access_token}

response = requests.get(url, headers=headers)#, timeout = 10) # in minutes, default 30 sec

 

if response.ok:

    content_stream = BytesIO(response.content)

else:

   print("Failed to retrieve document:", response.status_code)

   print(response.content)

   content_stream = None

``` The error message is:

```

Failed to retrieve document: status code 500 

b'{"error":{\r\n  "code": "generalException",\r\n  "message": "Error from Office Service. Url=https://euc.pptcs.officeapps.live.com/document/export/pdf HttpCode=InternalServerError cert=subject:;thumbprint: ResponseHeaders=X-ErrorCode: Service_Timeout\r\nX-ErrorCategory: Fatal\r\nX-IsRetriable: False\r\nX-FileDownloadTimeInMs: 1439.3197\r\nX-ClientCorrelationId: 06524ba1-f01a-0000-1ec4-6e5e55678cec\r\nX-ServiceCorrelationId: 06524ba1-f01a-0000-1ec4-6e5e55678cec\r\nX-ConversionTimeInMs: 28111\r\nCache-Control: private\r\nDate: Fri, 30 Aug 2024 11:03:04 GMT\r\nETag: ce20b453b92a5c7fd1763d507747c787d4220f5c2a782dbef02f35059f20b1de\r\nServer: Microsoft-IIS/10.0\r\nX-AspNet-Version: 4.0.30319\r\nX-Powered-By: ASP.NET\r\n",\r\n  "innererror": {\r\n    "code": "OfficeConversion_Fatal"\r\n  }\r\n}}'

```

I have also tried using Graph SDK and it returned the same status_code:

``` from msgraph import GraphServiceClient

from msgraph.generated.drives.item.items.item.content.content_request_builder import ContentRequestBuilder

from kiota_abstractions.base_request_configuration import RequestConfiguration

 

query_params = ContentRequestBuilder.ContentRequestBuilderGetQueryParameters(

format = "pdf",

)

 

request_configuration = RequestConfiguration(

query_parameters = query_params,

)

result = await graph_client.drives.by_drive_id(drive_id).items.by_drive_item_id(document_id).content.get(request_configuration = request_configuration)

```

Output:

```

APIError Code: 500  message: None  error: MainError(additional_data={'innererror': {'code': 'OfficeConversion_Fatal'}}, code='generalException', details=None, inner_error=None, message='Error from Office Service. Url=https://euc.pptcs.officeapps.live.com/document/export/pdf HttpCode=InternalServerError cert=subject:;thumbprint: ResponseHeaders=X-ErrorCode: Service_Timeout\r\nX-ErrorCategory: Fatal\r\nX-IsRetriable: False\r\nX-FileDownloadTimeInMs: 1531.2778\r\nX-ClientCorrelationId: 21524ba1-f036-0000-1ee9-fc1fb99d1922\r\nX-ServiceCorrelationId: 21524ba1-f036-0000-1ee9-fc1fb99d1922\r\nX-ConversionTimeInMs: 28136\r\nCache-Control: private\r\nDate: Fri, 30 Aug 2024 11:04:56 GMT\r\nETag: 2a0def08fe76865e45d6f5d4f3227822036da8ccfb5beee8002cb72bc182f4d0\r\nServer: Microsoft-IIS/10.0\r\nX-AspNet-Version: 4.0.30319\r\nX-Powered-By: ASP.NET\r\n', target=None)

```

Best regards,  Maryna

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

Accepted answer
  1. Hitesh Pachipulusu - MSFT 2,225 Reputation points Microsoft Vendor
    2024-09-02T13:44:49.1633333+00:00

    Hello

    Thank you for reaching to Microsoft Support!

    It looks like you’re encountering a common issue when converting large PowerPoint files to PDF using the Microsoft Graph API. The error message indicates a 500 Internal Server Error, which often points to a problem on the server side. Here are a few steps you can take to troubleshoot and potentially resolve this issue:

    1. Check File Size and Complexity: Large files with many slides or complex content can sometimes cause conversion issues. Try simplifying the content or splitting the presentation into smaller parts.
    2. Increase Timeout: Although you’ve already tried setting a timeout, you might need to increase it further. The conversion process for large files can take longer than expected.
    3. Retry Mechanism: Implement a retry mechanism in your code to handle transient errors. Sometimes, the server might be temporarily unable to process the request.
    4. Error Details: The error message includes details like X-ErrorCode: Service_Timeout and X-ErrorCategory: Fatal, which suggest that the service timed out. This might be due to the size and complexity of the file.

    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.


0 additional answers

Sort by: Most 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.