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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,557,444
Community Members
 
Community Events
184
Community Groups

Bitbucket Cloud Rest API - Deployments & Environments

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.
Jun 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

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.
Jun 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