Not able to merge pull request

Hi

I am trying to merge a pull request using the rest api. However I am getting an error when trying this

curl -X POST -k -H 'Content-Type: application/json; charset=utf-8' -H 'Authorization: Basic <<encoded value>>' -i 'https://api.bitbucket.org/2.0/repositories/lv_digital/code-commerce/pullrequests/1309/merge' --data '{
  "pullrequest_merge_parameters" : {
  type: "pullrequest",
  message: "Automated Commit for branch sync",
  close_source_branch: true,
  merge_strategy : "merge_commit"
}
}'

I always get a 400 error saying bad request. I checked the documentation and it does not really seem helpful. Any pointers as to what I might be doing wrong would be helpful

Regards
Tejas

Ah, yeah, when I run into error 400 I’ve learned it usually means my json is bad. In this case, you need quotes around your keys like so:

{
	"pullrequest_merge_parameters": {
		"type": "pullrequest",
		"message": "Automated Commit for branch sync",
		"close_source_branch": true,
		"merge_strategy": "merge_commit"
	}
}

Perhaps we should put quotes in our example docs so they’re easier to copy from (it took me a few minutes of staring to catch it).

1 Like

Thanks @sfarley. I knew it had to be something small. I did not realize the double quotes on the properties would cause this. Thanks!

Regards
Tejas

1 Like