# File listing returning 500 after upload

**URL:** <https://discuss.ai.google.dev/t/file-listing-returning-500-after-upload/47500>\
**Category:** Gemini API\
**Tags:** gemini-api\
**Created:** [November 2, 2024, 7:59am UTC](https://discuss.ai.google.dev/t/file-listing-returning-500-after-upload/47500 "2024-11-02T07:59:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![parakeet](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/parakeet/32/28177_2.png) [@parakeet](https://discuss.ai.google.dev/u/parakeet)\
**Post date:** [November 2, 2024, 7:59am UTC](https://discuss.ai.google.dev/t/file-listing-returning-500-after-upload/47500/1 "2024-11-02T07:59:19Z")

</div>

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

```auto
{
  "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

```auto
{
  "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](http://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…

```auto
{
  "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` - [https://ai.google.dev/api/files#method:-files.list](https://ai.google.dev/api/files#method:-files.list)

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

---

<div class="post-metadata">

**Author:** ![parakeet](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/parakeet/32/28177_2.png) [@parakeet](https://discuss.ai.google.dev/u/parakeet)\
**Post date:** [November 2, 2024, 8:26am UTC](https://discuss.ai.google.dev/t/file-listing-returning-500-after-upload/47500/2 "2024-11-02T08:26:18Z")

</div>

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