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

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

victorferreirait January 4, 2021

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

1 accepted

2 votes
Answer accepted
Iñigo Gonzalez
Atlassian Partner
January 5, 2021

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.

1 vote
Joao Sgreccia
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 5, 2021

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

1 vote
Gorka Puente _Appfire_
Atlassian Partner
January 5, 2021 edited

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!

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, team '25, conference, certifications, bootcamps, training experience, anaheim ca,

Want to make the most of Team ‘25?

Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.

Learn more
AUG Leaders

Upcoming Bitbucket Events