Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to filter environments by slug using the Rest API

Davide Bizzarri
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 18, 2024

I'm trying to retrieve the environment with the slug "production" with this request

 

http --verbose --auth username:app_password "https://api.bitbucket.org/2.0/repositories/org/repo/environments" q=="slug = \"production\""

 

which makes the following request:

 

GET /2.0/repositories/org/repo/environments?q=slug+%3D+%22production%22 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Authorization: Basic my_auth
Connection: keep-alive
Host: api.bitbucket.org
User-Agent: HTTPie/3.2.2

 

but instead of returning only the matching environment, the request returns all environments ignoring the filter.

 

Because the documentation [1] doesn't specify which filters are usable, I've tried to guess the request from the generic filter documentation [2], without success apparently

 

1. https://developer.atlassian.com/cloud/bitbucket/rest/api-group-deployments/#api-repositories-workspace-repo-slug-deployments-get

2. https://developer.atlassian.com/cloud/bitbucket/rest/intro/#filtering

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 23, 2024

Hi Davide,

I'm afraid that the environments endpoint does not support filtering at the moment.

What you could do is save the output of the API call in a file and then use another tool that filters JSON data (for example, jq is one such tool) to get the environment you want.

We have a request to support filtering for this endpoint: https://jira.atlassian.com/browse/BCLOUD-22285

You can add your vote to it (by selecting the Vote for this issue link) to express your interest.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events