A REST API request to manually trigger pull request rescoping is failing, resulting in an HTTP Status 400 – Bad Request error on Bitbucket Server

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

A REST API request to manually trigger pull request rescoping is failing, resulting in an HTTP Status 400 – Bad Request error on the Bitbucket Server.

Sample Curl Command or REST API call:

1 curl -v -u username -X POST -d '{"branches":[]}' -H "Content-Type: application/json" "http://example.com/projects/<PROJECT_KEY>/repos/<REPOSITORY_SLUG>/jobs/rescope-pull-requests"

Error Message after running the above command:

1 2 <!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).</p><hr class="line" /></body></html>* Closing connection 0 * schannel: shutting down SSL/TLS connection with bitbucket.hostname.com port 443

Environment

Tested on Bitbucket Server 7.21.7

Applied to Bitbucket Server 7.x

Cause

This issue generally occurs on Windows platform where ' (single quote) is not advised to use and it should be replaced with " (double quotes).

Solution

Issue should be resolved after using " (double quote) in place of ' (single quote) and if there are inner quotes also present then use """ (3x double-quotes).

So the command should be in the following format:

1 curl -v -u <admin_username>:<admin_password> -X POST -d "{"""branches""":[]}" -H "Content-Type:application/json" "<Bitbucket_BASE_URL>/projects/<Project_Key>/repos/<Repo_Sloug>/jobs/rescope-pull-requests"
Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.