Forums

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

Bitbucket Cloud Rest API - Deployments & Environments

Muffadal Hamid June 18, 2022

I am trying to filter & sort the deployments & environments rest api for bitbucket cloud but I am getting a 404 error below are the details.

 

This works

fetch('https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/environments/', {method:'GET', 
headers: {'Authorization': 'Basic ' + btoa('username:password')}})
.then(response => response.json())
.then(json => console.log(json));

 This gives 404. The only difference is the querystring. I have tried various combinations of

  • encoding the string
  • ending with / or ? or both
fetch('https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/environments?q=slug%3D%22canary-amr-qat-hardees%22', {method:'GET', 
headers: {'Authorization': 'Basic ' + btoa('username:password')}})
.then(response => response.json())
.then(json => console.log(json));

 

Is filtering & sorting not supported on these endpoints?

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 21, 2022

Hello @Muffadal Hamid ,

Welcome to Atlassian Community!

I'm afraid that sorting and filtering are not supported for the environments endpoint.

However, we already have a feature request to implement that functionality, which you can check at the following link: 

I would suggest you to add your vote there, since this helps both developers and product managers to understand the interest. Also, make sure you add yourself as a watcher in case you want to receive first-hand updates from that ticket. Please note that all features are implemented with this policy in mind.

While this feature is not implemented, you have the option to retrieve all environments via the API and then use another tool to filter JSON data, like jq, in order to filter the results.

Thank you, @Muffadal Hamid .

Kind regards,

Patrik S

Muffadal Hamid June 24, 2022

Thanks, @Patrik S for your response. The link you have posted talks only about the "environments" endpoint.  However, I am facing the exact same issue with the "deployments" endpoint below

 

https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/deployments?q=state.name="COMPLETED"
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 24, 2022

Hey @Muffadal Hamid ,

Actually, the feature request BCLOUD-18729 covers both the /deployments and /environment endpoints. 

You can check that the feature name is regarding the /deployments endpoint, and I have added a comment in the feature description to also mention the /environments endpoint that is having the same behavior and currently not allowing filtering and sorting.

Thank you, @Muffadal Hamid .

Kind regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events