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:
Google reCaptcha Enterprise Package for Laravel The Google reCaptcha Enterprise for Laravel is a package that provides easy configuration of reCaptcha and a handy validation rule to … Read More
Export Eloquent Models to JSON Files Model JSON for Laravel is a package that allows you to easily export data from specific models in your Laravel application to JSON format. … Read More
Encrypt environment files with Padlock Padlock is a Laravel Zero command by Daniel Mason for encrypting and decrypting environment files powered by Laravel's encryption comm… Read More
Saloon 2 is Here The Saloon package for PHP released version 2, rebuilt from the ground up with faster concurrency, retries, HTTP client agnostic design, solo re… Read More
Laravel Pennant Laravel Pennant is a package created by the Laravel team that will arrive with Laravel 10 provides Feature Flags for your applications… Read More
0 comments:
Post a Comment
Thanks