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

Bitbucket 2.0 PR difference api gives 404 when called from C# web application

Marilyn Pulinthitta July 15, 2023

I am using bitbucket's PR difference endpoint to get the differences for a PRID , it works on postman but the same call returns 404 via code.

I have checked the URL, Headers also has access token 

URL : https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/diffstat'

This api runs via Postman though. Also on checking the http response message, request message absolute is a different uri : https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/diffstat/{workspace}/{repo_slug}:30cff0b24f9a%0D6f7a3ddc9d21?from_pullrequest_id=1&topic=true

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 18, 2023

Hello @Marilyn Pulinthitta and welcome to the Community!

As per the Bitbucket API documentation, the endpoint Get diffstat for a Pull Request will return an HTTP Status Code 302 redirecting to Repository Diff stat with the commits that correspond to the Pull Request.

By default Postman follow redirects, so when you originally make a request to the pull request endpoint, bitbucket will respond with a redirect URL, and Postman will automatically make a new request to this redirect URL.

What might be happening is that your C# application is not configured to follow redirects. In this case, you might need to find any setting available on the tool you are using to enable follow redirects (HTTP 3xx responses), or you will need to make a second call to the API endpoint returned in the response message you shared in the description.

Hope that helps! Let me know in case you have any questions.

Thank you, @Marilyn Pulinthitta !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events