I'm trying to create a pull request on Bitbucket Server via Rest API, following this documentation. No matter what I try, I get a (400) Bad Request. error. I found this answer and used the body text from the answer (of course, replacing my information like the repo, branch, etc.):
{
"title": "My new PR",
"description": "This is my new PR.",
"state": "OPEN",
"open": true,
"closed": false,
"fromRef": {
"id": "refs/heads/this-is-my-branch",
"repository": {
"slug": "my-repo",
"name": 'My repo',
"project": {
"key": "KE"
}
}
},
"toRef": {
"id": "refs/heads/master",
"repository": {
"slug": "my-repo",
"name": 'My repo',
"project": {
"key": "KE"
}
}
},
"locked": false,
"reviewers": [
{
"user": {
"name": "jeremywat"
}
}
]
}
This is the request (I'm using PowerShell):
Invoke-RestMethod -Headers @{Authorization = "Basic $BasicAuth"} -Body $JsonBody -ContentType 'application/json' -Method POST -Uri
https://my-bitbucket-server.com/rest/api/1.0/projects/KE/repos/my-repo/pull-requests
/>
The example provided in the Atlassian documentation includes some additional information in the request body and I tried including all that info as well, but still receive the same (400) Bad Request. error.
I know the credentials ($BasicAuth) are correct because I can get PRs, comment on PRs, etc. via the API with the same credentials. I can also create a new PR from the Bitbucket web interface.
So can anyone tell me what I'm doing wrong and what's the correct way to accomplish this?
How to create a new Bitbucket pull request via API?
Programing Coderfunda
November 05, 2023
No comments
Related Posts:
SQL INSERT INTO Statement The SQL INSERT INTO StatementThe INSERT INTO statement is used to insert new records in a table.INSERT INTO SyntaxIt is possible to write the IN… Read More
SQL ORDER BY Keyword The SQL ORDER BY KeywordThe ORDER BY keyword is used to sort the result-set in ascending or descending order.The ORDER BY keyword sorts the reco… Read More
SQL NULL Values What is a NULL Value?A field with a NULL value is a field with no value.If a field in a table is optional, it is possible to insert a new record… Read More
SQL UPDATE Statement The SQL UPDATE StatementThe UPDATE statement is used to modify the existing records in a table.UPDATE SyntaxUPDATE table_nameSET colum… Read More
SQL AND, OR and NOT Operators The SQL AND, OR and NOT OperatorsThe WHERE clause can be combined with AND, OR, and NOT operators.The AND and OR operators are used to filter re… Read More
0 comments:
Post a Comment
Thanks