POST https://api.bitbucket.org/2.0/repositories/{{USERNAME]]/{{MS-NAME}}/refs/branches
with payload :
{
"name" : "staging",
"target" : {
"hash" : "default",
}
}
and got 400 Bad Request Response
{
"type": "error",
"error": {
"fields": {
"": "expected a dictionary"
},
"message": "Bad request"
}
}
Because the hash need to be defined with source branch
Hello Fauzan,
Thank you for including the endpoint you’re working with along with your JSON payload and the response. When you’re creating your API call, please ensure you’re using "Content-Type: application/json" to define the payload you’re delivering. Please attempt the call again with the content-type set as application/json and let us know the results.
Source documentation: /2.0/repositories/{username}/{repo_slug}/refs/branches
Regards,
Stephen Sifers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am still getting the same Bad Request error while creating the BB Branch from python script.
url="https://api.bitbucket.org/2.0/repositories/{workspace}/{repository}/refs/branches"
headers = {"Content-Type": "application/json"}
data={"name":"test-branch","target":{"hash":"master"}}
r = requests.post(url, auth=("username", "app_password"), headers=headers, data=data)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For anyone else finding themselves here, you can use the source branch as the hash e.g.:
-d '{ "name" : "develop", "target" : { "hash" : "master" } }'
This would create develop from master. Although, there seems to be a bug right now for me with the bitbucket UI that shows these only when I filter by merged (or all) branches.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Edit: It seems even if I create a branch in the UI then it only shows when I filter by 'merged' or 'all'. Presumably a temporary bug with the UI.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.