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:
Laravel Notification Log Laravel Notification Log is a package by Spatie to log notifications your Laravel app sends. This will allow you to query notification… Read More
Remove Sensitive Information from Laravel Apps Laravel Scrubber is a Laravel package to scrub sensitive information that breaks operational security policies from being leaked on ac… Read More
Creating Installer Commands for Laravel PackagesThe Laravel Package Tools package by Spatie added a nifty feature we wanted to help share with the community: streamlined install commands f… Read More
Mail SPF Checker for Laravel The Laravel Mail SPF Checker is a package to check if you can send an e-mail through a given mail server in the name of a given e-mail… Read More
Database Job Chains for LaravelLaravel Haystack is a package for beautifully simple but powerful database-driven job chains. Here's an overview of what is available, taken… Read More
0 comments:
Post a Comment
Thanks