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

Nemyrovska, Maryna 0 Reputation points
2024-08-30T14:49:53.97+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.
11,783 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,621 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Emily Du-MSFT 45,586 Reputation points Microsoft Vendor
    2024-09-02T07:17:41.8833333+00:00

    API Error500 is probably caused by the pptx file being too large, the backend server is under too much pressure to process data. For the large file (size greater than 4MB), it is not recommended to use Graph API to convert format.

    As a workaround, open the pptx file in the browser, click the File tab -> Export -> Download as PDF.

    1


    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.


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.