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

Diff for pull request using bitbucket api v2 gives 403 forbidden

Farhan Halai Apr 01, 2018

I am trying to check diff for the pull request using bitbucket api v2.

I am able to create the pull request using rest api but while merging I am getting merge conflicts so to check which file has conflicts, I am trying to check diff for the generated pullrequest.

But I am getting a 403 forbidden error.

Can someone please help me.

Thanks,

Farhan

2 answers

0 votes
IlyaFinkelshteyn Jun 25, 2018 • edited

It seems that it happens because redirect happens and authorization headers lost when in second request. This https://stackoverflow.com/a/28671822/6733637 should help (just check for HttpStatusCode.Forbidden).

Note however that this API did not help me with finding conflicts. I finally use trick described here https://community.atlassian.com/t5/Bitbucket-questions/REST-API-how-to-check-if-a-PR-has-conflict-s/qaq-p/716529#M28184

Jim Redmond Atlassian Team Jun 25, 2018

Why were you getting a redirect?

0 votes
IlyaFinkelshteyn Jun 25, 2018 • edited

@Jim Redmond because https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests/%7Bpull_request_id%7D/diff API officially returns `302` and many HTTP clients including .NET HttpClient does not pass authorization headers to the second request. 

Side question 1: What correct way to detect that PR is merge-able. The one I posted above with API V1?


Side question 2: Any chance PR ref (https://bitbucket.org/site/master/issues/5814/reify-pull-requests-by-making-them-a-ref) will be implemented? 

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

1,596 views 1 18
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