I try to make a pull request from a private repositorie. I have set up a password on personal settings -> apps password and set every permission on. (I uses this for bitbucketApiToken )
This is the script below i used:
use Illuminate\Support\Facades\Http;
$bitbucketApiToken = 'your_bitbucket_api_token';
$pullRequestTitle = 'Your Pull Request Title';
$sourceBranch = 'source_branch_name';
$sourceRepositoryFullName = 'workspace/source_repository_slug';
$destinationBranch = 'destination_branch_name';
$destinationRepositorySlug = 'destination_repository_slug';
$response = Http::withToken($bitbucketApiToken) ->post("https://api.bitbucket.org/2.0/repositories/$destinationRepositorySlug/pullrequests", [ 'title' => $pullRequestTitle, 'source' => [ 'branch' => [ 'name' => $sourceBranch, ], 'repository' => [ 'full_name' => $sourceRepositoryFullName, ], ], 'destination' => [ 'branch' => [ 'name' => $destinationBranch, ], 'repository' => [ 'full_name' => $destinationRepositorySlug, ], ], ]);
$responseBody = $response->json();
I get the message: Token is invalid or not supported for this endpoint