google-drive-api

Can I export Google Slides as HTML in the Drive API?


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.


Solution

  • 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