3

I'm stuck implementing a prototype to extract Google slides for other processing. When I try request = service_drive_v3.files().export_media(fileId=file_id, mimeType='text/html) on a Google slide I get:

<HttpError 400 when requesting https://www.googleapis.com/drive/v3/files/<FILE_ID>/export?mimeType=text%2Fhtml&alt=media returned "The requested conversion is not supported.". Details: "[{'domain': 'global', 'reason': 'badRequest', 'message': 'The requested conversion is not supported.', 'locationType': 'parameter', 'location': 'convertTo'}]">

The Google Drive reference says that Google slides can be exported to PDF and other formats including text/plain but not text/html.

However, https://docs.google.com/presentation/d/<FILE_ID>/export/html via a browser gives me a pretty nicely formatted HTML file just fine.

Is there a reason why the Drive API call fails even though Google seems to be able to export to HTML just fine? Is there a workaround.

Nic Cottrell
  • 9,401
  • 7
  • 53
  • 76
  • Also be aware that there is 10 Mb limit for exported files via API, see https://stackoverflow.com/q/50612407/555121 Fetching export URL result seems more productive – Kos Jan 14 '22 at 16:10

1 Answers1

2

There's no endpoint to export Slides as HTML in the google-api library. The version you get in /export/html is the one generated as {fileID}/pub when you publish a presentation to the web. The workaround you have found is pretty good.

You might want to create a async function to retrieve the file by using an HTTP request. My recommendation is to fill up a feature request to make that functionality available on https://developers.google.com/drive/api/v3/support#missing_features

David Salomon
  • 804
  • 1
  • 7
  • 24