Get list of pull requests in Repository - bitbucket

I want to get all pull requests in repository but this seems impossible. I was able to find only pull requests comments (https://confluence.atlassian.com/display/BITBUCKET/pullrequests+Resource)
How could one use this resource if he cannot get request ids? Is there any way to get pull requests?

The new API is now out and list of pull requests works fine
https://bitbucket.org/!api/2.0/repositories/YOUR_NAME/REPO_NAME/pullrequests

It is officially impossible. But promised to be fixed soon.

Related

fetch activities from bitbucket that were taken yesterday via api 1.0

I am monitoring lots of projects/repositories in Bitbucket server via API 1.0.
Retrieving projects, repos, pull requests and commits since last time I did is relatively easy: I have to save the IDs of the latest items (commits and pull requests) per repos I have already downloaded and add SINCE to the URL.
But I also want to monitor the actions taken to any pull request (reviewed, merged, commented, etc.) without teching their ids per repo and checking them in a loop.
Is there any way to monitor such activities somehow? Maybe fetching pull-requests that were updated since? Any help is very appreciated! Thank you in advance!

In AzureDevOps Server (on prem) how do I get the timestamp when I last looked at a Pull Request?

I'm using the Microsoft.VisualStudio.Services.Client library (added via NuGet) to connect to my on-prem Azure Dev Ops server and query various bits of information regarding pull requests. I'd like to make a little notification application that can alert me if someone has replied to a comment I made on a pull request. The trick is that I only want to see the notification if I haven't already looked at it.
I know that the system knows when I last looked at the pull request because it decorates pull requests with new content (comments, new code, etc.) with a little dot and when I open a pull request, it tells me that there are new comments since I visited last and tells me how long ago I looked at it.
How do I get access to the date that I opened the pull request in the web via the client libraries or REST? In other words, how would my app know that I have or haven't looked at new comments via the web page?
I did not find such an api that can retrieve the timestamp the last time you looked at the PR.
There is lastUpdatedDate you can use to track the comments that were checked. So as a workaround you can save the lastUpdatedDate to a file in your code, and compare this value everytime when you call api. Then you will get the latest updated comments.
However, PR comments notification can also be configured from azure devops. You can go to your user profile on the top right corner and select notifications to enable the notification for A comment is left on a pull request.
For more information about Azure devops notification, you can check this document.

Bitbucket - Retrieve a pull-request's tasks by REST api

I am assuming this is not possible but hoping it is.
I am using https://developer.atlassian.com/bitbucket/api/2/reference/ and trying to retrieve all tasks for a particular pull-request, but I can't figure out how.
Is it possible on Bitbucket Cloud (bitbucket.org)?
This is not currently possible - as I type this, the API returns the count of open tasks for a given PR (task_count in https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests/%7Bpull_request_id%7D), but not the content of those tasks.
It is not documented but, it works by sending GET call to below endpoint
https://api.bitbucket.org/2.0/repositories/TEAM/REPO_SLUG/pullrequests/PR_ID/tasks

How can I determine which Pull Request a commit belongs to using the GitHub API?

Given a commit SHA, I'd like to use the GitHub API to determine which pull request it belongs to.
GitHub displays this information on the commit page:
This information isn't in the API response for that commit, however:
curl --silent 'https://api.github.com/repos/hammerlab/pileup.js/commits/ee49f07dba3821109b3cf45404446f434a897558' | grep 328
(nothing)
Is it possible to get this information using the GitHub API? I realize that I could crawl all the recent PRs for the repo, but this seems inefficient.
For context: I'd like to do this from a Travis-CI "push" job, where I have access to the SHA but not any information about whether it's part of a pull request.
It seems to be possible using this new feature in the API v.3:
https://developer.github.com/v3/repos/commits/#list-pull-requests-associated-with-a-commit
This URL now redirects to:
https://docs.github.com/en/rest/reference/repos#list-pull-requests-associated-with-a-commit
This is the syntax:
GET /repos/:owner/:repo/commits/:commit_sha/pulls
It is possible, using the Search API, which supports this feature:
https://help.github.com/articles/searching-issues/#search-by-the-commit-shas-within-a-pull-request
For example:
https://api.github.com/search/issues?q=ee49f07dba3821109b3cf45404446f434a897558
returns a single result, which is this pull request:
https://api.github.com/repos/hammerlab/pileup.js/issues/328

Bitbucket new webhook not working

Bitbucket has improves its Webhooks functionality. We won't be able to create POST or Pull Request POST in Services, instead in Webhooks.
So I have tried to create POST request to Slack using new Webhook, but it doesn't work. Clicked on View requests, I got 500 error on the request. While with the same URL, it works in Services.
I don' know what I did wrong. Bitbucket documentation doesn't help. Can someone please help me?
I'm experiencing the same problem, and it appears to be a known issue with the integration (from the perspective of Slack).
As documented on slack.com:
This integration only supports the Repository push trigger at this
time, so make sure it is selected. Press Save when you're done.
I'm not sure where to find a public link to this document, but you can find it if you go to add the bitbucket integration. And the documentation on slack appears to be up to date with the new bitbucket webhooks.
Hopefully one of the parties fixes it soon.
Update:
The integration appears to have started working in the last couple of days. At least for us with PR create/update/comment?approve/merge.
Maybe Graham is talking about this here. You maybe need to change your IP-whitelist to connect to your server.
131.103.20.160/27 165.254.145.0/26 104.192.143.0/24.
I never used Posthooks. I m myself struggeling with the webhook configuration.
Not sure if this is related to your issue, but I'm putting it here as it might help others, there's currently an open issue related to non-standard ports that has similar symptoms:
https://bitbucket.org/site/master/issue/11514/webhook-fails-when-using-an-alternative
Do you have any IP limits on what IPs can post to that end target? The new web hooks may be using different IP addresses than the old services.

Resources