Hi all,
I am trying to call the REST API [ with the correct authentication ] with the following:
https://api.bitbucket.org/2.0/repositories/foo/bar/environments?q=name="Test"
According to the docs this should return all environments, in foo/bar, with a name of "Test" but it just brings back all the environments. I get similar results when trying to use ?sort [ order doesn't change ] and ?fields [ all the environments data is returned rather than the fields I list ]
Am I missing something obvious here ? Or does filtering/sorting/partial responses not actually work ?
Regards,
Adam
Hi Adam,
I'm afraid that this API endpoint does not support sorting or filtering at the moment. Partial responses with the fields query parameter are possible, the way Saxea _Flowie_ explained.
We have a feature request in our issue tracker for supporting filtering and sorting for this endpoint:
You can add your vote there to express your interest.
In the meantime, you can get all the environments with the API, and then use another tool that filters JSON data to filter the results (e.g. jq is such a tool).
Kind regards,
Theodora
Hi @Adam Brunt ,
Not a solution, but I tested and can confirm I'm seeing the same behaviour.
The APIs usually error when you use a field that is not filterable. However with this one, it doesn't fail, no matter what you use as filter, and it doesn't respect the pagelen and sort also.
The fields is the only one that seem to work. Note you have to use fields=values.name.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Saxea _Flowie_ for confirming I wasn't going mad :)
To be fair, the documentation does say "Most 2.0 API resources that return paginated collections" but it would be helpful, in that case, to state in the docs which ones don't !!
Luckily in our case, we only have 4 environments so it's not such an issue to search through all the results; just so long as the pipelines endpoint does support filtering & sorting.
I will also try the values. part as well.
Now to do some investigating on how to filter by several fields (some of them nested deep down) at the same time :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.