How to get a list of pipelines and deployments with the API
Asked by victorferreirait:

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?


Answers:
author: I?igo Gonzalez
body: 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.


author: Joao Sgreccia
body: Hi [@victorferreirait](/t5/user/viewprofilepage/user-id/3931928) ,  

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
```

<br />

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
```

<br />

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

Cheers


author: Gorka Puente _Appfire_
body: Hi Victor,

My colleague [I?igo Gonzalez](https://community.atlassian.com/t5/user/viewprofilepage/user-id/4205419 "I?igo Gonzalez [RoninPixels]") 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.
>
> <br />
>
> Try with these urls:
>
> <br />
>
> <https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pipelines/>
>
> <br />
>
> <https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/deployments/>
>
> <br />
>
> 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!


Tags: bitbucket-cloud

bitbucket-development

cloud