0

I'm trying to add an image that I've uploaded to Drive via the Drive API into a slide show I've created using the same API.

when Running the fairly standard:

response = (self
           ._slides_service
           .presentations()
           .batchUpdate(presentationId=slide_deck_id, body=body)
           .execute()
           )

I get:

googleapiclient.errors.HttpError: <HttpError 400 when requesting {url} returned "Invalid requests[0].createImage: The provided image is in an unsupported format.">

I'm generating the service in the same way as suggested in the documentation here: https://developers.google.com/slides/quickstart/python

My scope is:

https://www.googleapis.com/auth/presentations

If I run the command with a random png from the internet then it inserts the image fine. I've tried the url provided by webContentLink or WebViewLink values from the response from uploading the images. Neither are valid.

What URL will work to do this?

I'm aware there are other similar questions on stack overflow but all of them are not related to doing this in python or if they are, there solutions don't work.

EDIT: body is:

{'requests': [{'createImage': {'url': url, 'elementProperties': {'pageObjectId': page_id}}}]}

had to generalise the url and page id because GDPR is a pain.

Alesi Rowland
  • 379
  • 2
  • 16
  • 1
    Can you provide the value of `body` for replicating your issue? – Tanaike Apr 02 '20 at 11:49
  • Thank you for adding the information. I noticed your updated question just now. I deeply apologize for this. I could confirm that your request body is correct. So for example, is this thread useful for your situation? https://stackoverflow.com/q/60076883 In this thread, an image on Google Drive is put to the Google Slides using Slides API. In this case, `replaceAllShapesWithImage` and Google Apps Script are used. But this method can be also used for `createImage` and googleapis of python. If this was not useful for your situation, I apologize. – Tanaike Apr 03 '20 at 02:11

0 Answers0