The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

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

DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events