GraphQL Internal Server Error for R2

For Workers & Pages, what is the name of the domain?

None

What is the error number?

No error, just a 200 response

What is the error message?

Internal server error

What is the issue or error you’re encountering

Calling r2StorageAdaptiveGroups results in Internal Server Error

What steps have you taken to resolve the issue?

Not resolved, but tested the following:

  • Removed filters
  • Ensured Account ID and Bucket Name are all correct
  • Played around with the date to make sure it is not a date issue, e.g. date too long in the past

What are the steps to reproduce the issue?

query {
  viewer {
    accounts(filter: { accountTag: "<account ID here>" }) {
      r2StorageAdaptiveGroups(
        limit: 100
        filter: {
          datetime_geq: "2025-01-01T00:00:00.000Z"
          datetime_leq: "2025-01-04T00:00:00.000Z"
          bucketName: "<bucket name here>"
        }
        orderBy: [datetime_DESC]
      ) {
        max {
          objectCount
          uploadCount
          payloadSize
          metadataSize
        }
        dimensions {
          datetime
        }
      }
    }
  }
}

I could not get it working using GraphQL even though I used this as reference: https://developers.cloudflare.com/r2/platform/metrics-analytics/

Any case, found this and it works: https://community.cloudflare.com/t/api-get-bucket-size-and-number-of-class-a-b-operations/504176/3

Here is the cURL:

curl --location 'https://api.cloudflare.com/client/v4/accounts/ACCOUNT_KEY_HERE/r2/buckets/BUCKET_NAME_HERE/usage' \
--header 'Authorization: Bearer xxxx' \

It seems that the permissions you need for your API key is:

  • Workers R2 Storage:Read
  • Workers KV Storage:Read

Ther permissions did take a while to take effect.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.