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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to build commit statuses with API 2.0?

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

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
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,892 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you