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

Authentication error on pull requests/{id}/diffstat

Manatee October 26, 2022

Hello, Im trying to call this API using an APP password but Im getting rejected with this error.
What can I do?

{

    "type": "error",

    "error": {

        "message": "The requested repository either does not exist or you do not have access. If you believe this repository exists and you have access, make sure you're authenticated."

    }

}

 

I tried multiple app password with all permissions.
Im using postman and passing my username and app password with Basic Auth as documentation suggested.
I can't use OAuth 2.0, it is even possible?
Because every other single call works.
Thank you

1 answer

0 votes
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 26, 2022

Hi @Manatee,

Thank you for reaching out to the community.

For us to test your app password and the API endpoint, would you be able to run the below CURL command on your local machine instead of Postman?

curl -I -u bb_username:app_password "https://api.bitbucket.org/2.0/repositories/workspace_id/repo_name/pullrequests/pr_id/diffstat"

Let's see if you're getting the 302 response according to the API endpoint documentation.

Let me know how it goes.

Regards,
Mark C

Manatee October 27, 2022

Hi, it work and I get 302 but Im not understanding what I have to do.
Because I tried using a Bearer and I get the info I was looking for, but I can't use it in my application

Manatee October 27, 2022

Also I noticed that I was using as endpoint: bitbucket.org instead of api.bitbucket.org
OMG, this was the error. So everything fixed now :D

Manatee October 27, 2022

The API anyway worked using bitbucket.org/api/2.0/ but it wasn't the correct one

Manatee October 27, 2022

I will explain which was my final goal, maybe you can help :)
We open a pull request on Bitbucket with a merge conflict.

Now assuming that we don't know that there is a merge conflict, we want to know if there is one, using API, so we tried calling the API GET pull request/id but the answer doesnt say nothing about the merge conflict warning.  Now we are looking for other API but there doesnt seem to be one

Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 28, 2022

Hi @Manatee

You can actually extract the "location" value from the response header of the API result.

Once extracted, you can use the URL to run another API command.

curl -u bb_username:app_password "<URL here>"

The result will be in JSON format and you can find the status with the "merge conflict" value. That means the file has a merge conflict.
e.g.

"status" : "merge conflict",


Hope it helps.

Regards,
Mark C


Manatee October 28, 2022

Hi @Mark C 

On which API are u referring?
I tried on Postman: 
GET https://api.bitbucket.org/2.0/repositories/chrmancini89/test/pullrequests/9/diffstat
GET https://api.bitbucket.org/2.0/repositories/chrmancini89/test/pullrequests/9
But none of them have some field called "location", there is only one named: "X-Dc-Location" with a value of "Micros-3".
Do you mind to be more precise about it?
Thank you for your super help

Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 31, 2022

Hi @Manatee

I'm not sure exactly how to do the same on Postman but I do see the "location" response header while using the CURL command below and run it on the terminal/command prompt:

curl -I -u bb_username:app_password "https://api.bitbucket.org/2.0/repositories/workspace_id/repo_name/pullrequests/pr_id/diffstat"


The URL is something like this:

location: https://api.bitbucket.org/2.0/repositories/workspace_id/repo_name/diffstat/workspace_id/repo_name:commit_hash?from_pullrequest_id=123


Regards,
Mark C

Suggest an answer

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

Atlassian Community Events