Problem filtering builds using Cloud SDK and API

I’m having trouble getting filters to work when using the Cloud API to list builds.

This Cloud SDK call works fine:

gcloud builds list --filter=buildTriggerId=d5e674ac-2978-42e1-a490-633b76142d48

But when using the API

GET https://cloudbuild.googleapis.com/v1/projects/{projectId}/builds

It fails with “INVALID_ARGUMENT Request contains an invalid argument.”

The API is working when I filter on ‘status’ but I get the above error when I try to filter on other properties like buildTriggerId, name or id.

The documentation I’ve found is patchy, and I can’t understand why the SDK and API behave differently.

Is anyone using the filters successfully?

As shown in the documentation, you can use the supported fields for queries as a filter query parameter:

filter The raw filter text to constrain the results.

For example, here is sample request:

GET https://cloudbuild.googleapis.com/v1/projects/[projectID]/builds?filter=trigger_id%3Dd5e674ac-2978-42e1-a490-633b76142d48&key=[YOUR_API_KEY] HTTP/1.1

Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json

Thank you very much! I hadn’t managed to find that first documentation link. That’s what I needed.