Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED] Can't open a pull request from the REST api

Aviad Reich
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 21, 2017

trying to open a new pull request from the REST API, according to https://developer.atlassian.com/static/rest/stash/3.11.6/stash-rest.html#idp3191968

Using this:

curl -i -X POST -u $USERNAME:$PASSWORD -H "Content-Type: application/json" http://bitbucket-server.on.my.net/rest/api/latest/projects/\~MY-USER/repos/MY-REPO/pullrequests --data '{"title": "title", "description": "let us fix it", "state": "OPEN", "open": true, "closed": false, "fromRef": { "id": "refs/heads/branch-with-commits", "repository": { "slug": "MY-REPO", "name": null, "project": { "key": "~USERNAME" } } }, "toRef": { "id": "refs/heads/master", "repository": { "slug": "MY-REPO", "name": null, "project": { "key": "~USERNAME" } } }, "locked": false, "reviewers": [] }'

 

I get: 


HTTP/1.1 404
X-AREQUESTID: @1YZE055x940x74072x0
X-ASEN: SEN-9670286
X-AUSERID: 52
X-AUSERNAME: USERNAME
Cache-Control: no-transform
X-Content-Type-Options: nosniff
Vary: Accept
Content-Type: application/xml
Transfer-Encoding: chunked
Date: Tue, 21 Nov 2017 15:40:27 GMT
Via: 1.1 google

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>404</status-code><message>null for uri: http://bitbucket-server.on.my.net/rest/api/latest/projects/~USERNAME/repos/MY-REPO/pullrequests</message></status>

1 answer

0 votes
Aviad Reich
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 21, 2017

eventually, this worked (docs need fixin'):

 curl -i -X POST -u $USERNAME:$PASSWORD \
-H "Content-Type: application/json" \
http://HOST/rest/api/latest/projects/\~USERNAME/repos/[lower-case-repo-name]/pull-requests \
--data '{"fromRef":{"id":"branch-with-commits","repository":{"slug":"lower-case-repo-name","name":"MY-REPO","project":{"key":"~USERNAME"}}},"state":"OPEN","title":"fix some issues","description": "let us fix it","toRef":{"id":"master","repository":{"slug":"lower-case-repo-name","name":"MY-REPO","project":{"key":"~USERNAME"}}}}'

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events