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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get a list of pipelines and deployments with the API

When I use the API to get a list of Pull Requests with

https://bitbucket.org/api/2.0/repositories/<workspace>/<repo_slug>/pullrequests?access_token=sometoken I receive a 200 as a response.

Following the documentation I should do the same for a list of deployments or pipelines

https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pipelines/

https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/deployments/

But when I send by GET request I receive 404 instead and the message:

'There is no API hosted at this URL.\n\nFor information about our API\'s, please refer to the documentation at: https://developer.atlassian.com/bitbucket/api/2/reference/'

Please notice that the required path params in the documentation are username and repo_slug for both the deployments and pipelines. But it's not the same as stated in the list of endpoints.

Plus, what is the username? It says "The account". What account? And if it is really necessary where and how should I inform this?

3 answers

Hello Victor,

I have checked and probably the URL you are using is wrong. Bitbucket V2 apis are hosted under https://api.bitbucket.org/2.0 url, while for the first call you are using https://bitbucket.org/api/2.0. I do not know, but probably that is an old implementation and works with the pull requests because there has been there for ages, while pipelines and deployments is something newer.

 

Try with this urls:
https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pipelines/

https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/deployments/

The last slash is important, I think in my case it wasn't working for me due to not writing it.

 

Another thing, I see that you put the access token as query param. Where does that access token come from? Because as far as I know the auth info has to go in the request headers.

Hi Victor,

 

My colleague Iñigo Gonzalez saw your question and wanted to answer, but he's having issues with posting with his own account. Here's the answer he was gonna publish:

I have checked and probably the URL you are using is wrong. Bitbucket V2 apis are hosted under https://api.bitbucket.org/2.0 url, while for the first call you are using https://bitbucket.org/api/2.0. I do not know, but probably that is an old implementation and works with the pull requests because there has been there for ages, while pipelines and deployments is something newer.


Try with these urls:


https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pipelines/


https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/deployments/


The last slash is important, I think in my case it wasn’t working for me due to not writing it.
Another thing, I see that you put the access token as query param. Where does that access token come from? Because as far as I know the auth info has to go in the request headers.

 

Hope this helps!

0 votes

Hi @victorferreirait ,

It is only a guess based on the provided information.

The only difference between these endpoints is the "/" at the end of the deployments and pipelines endpoint.
- pullrequests: /2.0/repositories/{workspace}/{repo_slug}/pullrequests
- deployments: /2.0/repositories/{workspace}/{repo_slug}/deployments/
- pipelines: /2.0/repositories/{workspace}/{repo_slug}/pipelines/

If you don't add the / at the end of the URL for pipelines and deployments you would receive this response

curl -u jsgreccia:<myapppassword> https://api.bitbucket.org/2.0/repositories/<workspace>/<repo_slug>/pipelines -v
< HTTP/2 404
{"type": "error", "error": {"message": "Resource not found", "detail": "There is no API hosted at this URL.\n\nFor information about our API's, please refer to the documentation at: https://developer.atlassian.com/bitbucket/api/2/reference/"}}* Closing connection 0

 
If you add the "/" at the end

 

curl -u jsgreccia:<myapppassword> https://api.bitbucket.org/2.0/repositories/<workspace>/<repo_slug>/pipelines/ -v
< HTTP/2 200


I hope that is the issue, if not please provide more information. I would be happy to help.

Cheers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Bitbucket

Contest: Share your custom Bitbucket Pipe and win

Announced in this blog, this holiday season we’re celebrating all things CI/CD and between now and the end of 2019 we’ll be showcasing content, use cases, feature announcements and more. One featur...

2,132 views 11 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you