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

Diff for pull request using bitbucket api v2 gives 403 forbidden

farhan_h April 1, 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 June 25, 2018

@jredmond 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? 

0 votes
IlyaFinkelshteyn June 25, 2018

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

jredmond
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 25, 2018

Why were you getting a redirect?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events