0

I'm facing a really bizarre issue with the Google Docs API when trying to replace placeholder images. Initially, my code ran without any issues, successfully replacing hundreds of images. However, when I tried to repeat the process later the same day, I encountered the following error:

An error occurred: <HttpError 400 when requesting https://docs.googleapis.com/v1/documents/1vietGZI8_qGa1d79dtFvQxN-NcKQGJpkIUJPw2NfqEs:batchUpdate?alt=json returned "Invalid requests[0].replaceImage: Access to the provided image was forbidden.">

The image I am trying to use is definitely publicly accessible, so I'm not sure what is causing the issue. As far as I know, no one has updated the permissions of our Google account. The only thing I can think of is that there might be an issue with the Google API for batchUpdate replace image.

Has anyone else encountered this problem, or does anyone have any suggestions on how to resolve it? This issue occurred on the same day – the queries ran fine in the morning, but I got the error in the evening.

I've tried various approaches to resolve the issue, including changing the image URL from the previously working WebContentLink to WebViewLink, but that didn't help. All the images I'm using are SVG files, have a size of less than 15 KB, and are publicly accessible, which I've confirmed by accessing them in a private browser mode.

Interestingly, when I tried using the thumbnail link instead, the images were added to the Google Doc successfully, but the resolution was too low to meet my requirements. This led me to suspect that there might be some obscure quota limits or other restrictions at play. However, even after waiting for a few days and trying again, I faced the same problem.

I'm wondering if anyone knows whether any changes were made on Google's end that could have affected the use of the same images under the batchUpdate replaceImage operation. What could be causing this issue, and how can I resolve it?

Roche
  • 1
  • About `Interestingly, when I tried using the thumbnail link instead, the images were added to the Google Doc successfully, but the resolution was too low to meet my requirements.`, in this case, I thought that this thread might be useful. https://stackoverflow.com/a/58985061 In order to use the large size of the thumbnail image, how about modifying the link from `https://###.googleusercontent.com/###=s220` to `https://###.googleusercontent.com/###=s1000`? But, I'm not sure whether this is the direct solution to your issue. If this was not useful, I apologize. – Tanaike Apr 07 '23 at 08:28

0 Answers0