Files.list method fails with 500

Hi, all!

Currently it appears that files.list method fails sporadically with a 500 error.

Basically, here’s what I do:

$ curl -H 'x-goog-api-key: my-api-key' https://generativelanguage.googleapis.com/v1beta/files
{
  "error": {
    "code": 500,
    "message": "Failed to convert server response to JSON",
    "status": "INTERNAL"
  }
}
$

Is there anyone else seeing this problem? Happy to provide more info (e.g. the project ID), feel free reach out to me in PM.

1 Like

While calling files.list fails randomly, it seems like specifying a URL parameter with any integer value makes it fail 100% of the time:

curl https://generativelanguage.googleapis.com/v1beta/files?pageSize=11
1 Like

Good to know, thanks for sharing

I have a test case that exercises the list operation with pageSize=3, primarily to test how my code is handling the continuation pageToken. I ran it a lot, no problems. Maybe the way you combined the get parameters (api key and page size) is causing you trouble?

I am passing API key in a header, but pageSize as a GET parameters. Are you saying it might be worth trying to pass API key in GET parameter too?

It’s worth a try. Special Header for API key should work fine too. What I have and works is either 2 or 3 GET parameters, depending on whether this is a continuation result.

        params={
            "key": mykey.get("google"),
            "pageSize" : pageSize
        }
        if pageToken != None:
            params["pageToken"] = pageToken
            
        r = requests.get(target_url, params)
        if not 200 <= r.status_code < 300:

Hope that helps!