File listing returning 500 after upload

Why does a GET request to the /files endpoint always result in a 500 error?

{
  "error" : {
    "message" : "Failed to convert server response to JSON",
    "status" : "INTERNAL",
    "code" : 500
  }
}

Happens with…

API key as parameter:

  • myhttps://generativelanguage.googleapis.com/v1beta/files?key=API_KEY
  • myhttps://generativelanguage.googleapis.com/v1beta/files/FILE_ID?key=API_Key

API key as X-Goog-API-Key header:

  • myhttps://generativelanguage.googleapis.com/v1beta/files
  • myhttps://generativelanguage.googleapis.com/v1beta/files/FILE_ID

What I’m doing

  1. I have uploaded a video file by opening a **start** resumable upload session via POST…
  • X-Goog-Upload-Command: start
  • X-Goog-Upload-Header-Content-Length: my file size
  • X-Goog-Upload-Header-Content-Type: video/mp4
  • X-Goog-Upload-Protocol: resumable
  • Content-Type: application/json
  • Body type: raw, JSON
{
  "file": {
    "display_name": "input_video.mp4"
  }
}

myhttps://generativelanguage.googleapis.com/upload/v1beta/files?key=API_KEY

  1. Doing a upload, finalize call, also via POST…
  • X-Goog-Upload-Command: upload, finalize
  • X-Goog-Upload-Header-Content-Length: my file size
  • X-Goog-Upload-Offset: 0
  • Body type: multipart/formdata of type “file” with key “data” (I don’t know a way to set —data-binary in my environment, which is Make.com)

“data” is sent as `“data”: "IMTBuffer(574823, binary, 870e811c2fcd089bfa5ffc14eb674b2f1a793a72…a etc.

This returns a “state” of “PROCESSING” or “ACTIVE”, I guess it depends on the file size/speed of upload?

  1. But all attempts to check the file by its URI or even get a listing of files fail with 500.

Eg. Myhttps://generativelanguage.googleapis.com/v1beta/files/FILE_ID as GET, with API key either in parameter or header, whether with FILE_ID or without…

{
  "error" : {
    "message" : "Failed to convert server response to JSON",
    "status" : "INTERNAL",
    "code" : 500
  }
}

I’ve read many theories about this error on this forum, but I can’t solve it.

Here’s the doc for /files - Using files  |  Gemini API  |  Google AI for Developers

(I’ve had to obfuscate my URLs here because the forum system will only allow two).

Oh, I think this stems from not having properly uploaded the data as binary.