Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to build commit statuses with API 2.0?

Will Baizer January 6, 2020

Currently, I am trying to create a build status for a pull request commit through Bitbucket's new API 2.0

https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/commit/%7Bnode%7D/statuses/build

However, the documentation for this API call is confusing as the request body is the exact same as the response body (like it is calling for the uuid of the commit status I have yet to create).

So, I instead used the old request structure from API 1.0:

{
	"state": "<INPROGRESS|SUCCESSFUL|FAILED>",
	"key": "<build-key>",
	"name": "<build-name>",
	"url": "<build-url>",
	"description": "<build-description>"
}

I send this request (with the proper authorization and all) to:

https://api.bitbucket.org/2.0/repositories/<my-workspace>/<my-pullrequest>/commit/<commit-sha>/statuses/build

with request a request body structured:

{
"state": "INPROGRESS",
"key": "build",
"name": "Hello World",
"url": "https//www.pullrequest.com",
"description": "YAY!"
}

...and am met by this:

{ 
"type": "error",
       "error": {
              "message": "Bad request"
}
}

So it is apparent that the old request body is either outdated, I am miss reading the current API documentation, or the current API documentation needs to be updated.

Has anybody else correctly built a commit status with the new API? If so, how was the request built?

1 answer

0 votes
Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 7, 2020

Hello @Will Baizer,

Thanks for reaching out.

The documentation is indeed confusing there, we'll look into improving it.

The request body you posted looks good to me. I think you didn't specify Content-Type: application/json header, can you confirm this?

Hope this helps.

Cheers,
Daniil

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events