I would like to access information about all pull requests that are linked to a particular work item.
The relations on a work item result (e.g. https://.../_apis/wit/workItems/12345?$expand=all) shows links to the pull requests in this form:
vstfs:///Git/PullRequestId/...
How can I turn that relationship URI into the canonical URL for the pull request using the VSTS REST API? (e.g. https://.../_apis/git/repositories/.../pullRequests/1234)
To parse information of the GET Pull Request REST API from the response of GET work item REST API, you just need to get the pull request id.
From the response of the GET work item REST API, you can get the pull request URL as:
vstfs:///Git/PullRequestId/f7855e29-6f8d-429d-8c9b-41fd4d7e70a4%2Fe89075b8-d7bd-4c3f-b24c-23276d89e8ec%2F106
Then get the pull request, you can split the string with %2F, then the pull request id is the last part (as the pull request id is 106 in above example).
And to get the pull request detail by the rest api as below:
GET https://{account}.visualstudio.com/_apis/git/pullrequests/{pullrequestID}?api-version=4.1
Related
Using the Bitbucket REST API, I’m looking for a way to get all pull requests that are assigned to a user. So far this endpoint: https://api.bitbucket.org/2.0/repositories/{workspace}/{repository_name}/pullrequests/{pullrequest_id}?fields=reviewers will show me the reviewer assigned to that specific pull request ID. Is there a way to do that, but not for a specific pull request, rather all pull requests assigned to a user?
So I have implemented the Asana Webhooks API as described in their documents. I can pass it a project ID and request a new webhook be created. The API successfully sends a authentication request to my application which returns the Security header as described in the Docs. Asana then returns the expected success response, outlining the newly created Webhooks unique ID.
Now if i take this ID and then query the Asana API to show me all configured webhook's on either the parent Workspace or the project resource directly it returns an empty data JSON Object or reports the resource doesn't exist, suggesting the Webhook Ive just created wasn't actually created, despite giving me the expected success response.
Also If I then make a change to a project it doesn't fire the webhook and I don't receive any events on my application.
Strangely everything was working on Friday but today (Monday) I'm experiencing these issues.
Any pointers would be good, Ive been working as the Docs suggest in terms of my request structure and am authenticating using a PAT, Ive even tried a newly created token.
Thanks,
Our webhooks use the handshake mechanism to make sure that it's possible to call you back, but there's always the possibility that subsequent requests can fail. Additionally (although we don't document this very well - there's an opportunity for us) we should immediately try to deliver a (probably) empty event after the handshake (it looks like {"events":[]}. This is kind of like a "second callback" that contains anything that has changed since you created the webhook.
If this fails - or if any subsequent request fails often enough - the webhook will get trashed. "Failure" in this context means returns HTTP response codes other that 200 or 204.
As for why you're having trouble querying the webhook itself, I wasn't able to repro the issue, so we'd have to dive deeper. It should be fine if you:
Specify the workspace
Optionally specify the resource
I tested this out, and it seemed fine. You also might want to directly query the webhook by id with the /webhooks/:id endpoint - note to use the id of the webhook returned by create, and not the id in the resource field.
If you created the webhook (specifically, your PAT or OAuth app was the one making the create request) you should see the information just fine. If you can get the webhook by id, you should see last_failure_at and last_failure_content fields which would tell you why the webhook was unable to make the delivery.
Finally, if you would like to contact us at api-support#asana.com and let them know more details (for instance, the ID of the webhook you're trying to look at) we can look at those fields from our side to see if we can identify what's going on.
I'm experimenting with the Mendeley API to upload and retrieve documents and files and have a problem with the files/{file_id} endpoint.
I have a personal Mendeley account I'm using for testing, populated with some PDF documents.
For example, on the API documentation page if I call
GET /files
I see all the files I've added, but if I take an id value, then call
GET /files/{file_id}
using the ID, e.g.
https://api.mendeley.com:443/files/7b188de2-32a7-f067-51bd-520179e866b8
I get a strange response code of 0, response headers is {}, response body is 'no content'. This happens with all the ids from the file listing - is this a bug or am I doing something wrong?
If I alter the id string, I get a 404 Not found error, which is to be expected, so it's not an authorisation or other general issue.
It's a limitation of Swagger, the software that's used to run the API documentation web page.
That endpoint returns a redirect to an S3 download URL, to allow you to grab the file. Unfortunately Swagger doesn't handle the redirect properly, and it shows it as a response code of 0.
The endpoint is working correctly; it's just not displaying properly on the documentation page.
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
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.