Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

REST API 2.0 (https://api.bitbucket.org/2.0/repositories/workspace_id) return no data

lukas_kubicek March 18, 2025

Hi,

I'm trying to get list of all ours repositories via REST API

https://api.bitbucket.org/2.0/repositories/workspace_id where workspace_id = our valid workspaceId  ... we received HTTP 200 but in response body is only:

{"values": [], "pagelen": 10, "size": 0, "page": 1}

even we have many repositories and user used for REST auth. has permition for all those repositories.

1 answer

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 19, 2025

Hi Lukas and welcome to the community!

The 200 response indicates that the authentication details are valid, but the fact that you get no data usually means that the authenticated user or access token doesn't have permissions to get the repos.

What type of authentication do you use for this API call? Do you use the username and app password of a user, or do you use an access token (if so, what type of access token is it, repository, project, workspace, or oauth access token)?

If you use username and app password, are they credentials of your own Bitbcuket account or of another user? If you use a different user for authentication, does the call work if you authenticate with your own user, as follows:

curl -v -u username:app_password --request GET \
--url 'https://api.bitbucket.org/2.0/repositories/workspace-id' \
--header 'Accept: application/json'

I'm just asking to better understand the scope of the problem.

If you execute the problematic call again and you give me the date and time (in UTC) that you did this, I can also check our API logs for the authenticated user and the logs may shed some more light on what is happening.

Kind regards,
Theodora

lukas_kubicek March 20, 2025

Hi Theodora,

I'm using my account which has ADMIN right and should have permission to all our repos. So I use userName and app password.

I've just tried it with same result ... 20.3.2025 8:10 CET .. but Time in response header is different ... I guess you have some cache on your side..

If it helps here are some data from response:

date: Thu, 20 Mar 2025 06:59:37 GMT
server: AtlassianEdge
vary: Authorization, Origin, Accept-Encoding
x-view-name: bitbucket.apps.repo2.api.v20.repo.RepositoriesHandler
x-used-mesh: False
x-dc-location: Micros-3
x-served-by: 750407edb127
x-version: ff05a03a9359
x-static-version: ff05a03a9359
x-request-count: 1273
x-render-time: 0.0605311393737793
x-b3-traceid: c610b44815534fb08cb2a1b65f302b0a
x-b3-spanid: e6b531e88896dc90
x-usage-user-time: 0.037834
x-usage-system-time: 0.000000
x-usage-input-ops: 0
x-usage-output-ops: 0
atl-traceid: c610b44815534fb08cb2a1b65f302b0a
atl-request-id: c610b448-1553-4fb0-8cb2-a1b65f302b0a
x-trace-id: c610b44815534fb08cb2a1b65f302b0a
report-to: {"endpoints": [{"url": "https://dz8aopenkvv6s.cloudfront.net"}], "group": "endpoint-1", "include_subdomains": true, "max_age": 600}
nel: {"failure_fraction": 0.001, "include_subdomains": true, "max_age": 600, "report_to": "endpoint-1"}
server-timing: atl-edge;dur=171,atl-edge-internal;dur=4,atl-edge-upstream;dur=168,atl-edge-pop;desc="aws-eu-central-1"
content-type: application/json; charset=utf-8
content-length: 51
x-accepted-oauth-scopes: repository
etag: "9ef7a6f96b3f98d05691462d9b5feda5"
x-frame-options: SAMEORIGIN
cache-control: max-age=900
x-content-type-options: nosniff
x-xss-protection: 1; mode=block

 

Thank you for trying to help me

Lukas

lukas_kubicek March 21, 2025

Hi again ...

I also tried different access ... I created OAuth Consumer with read rights and get access_token ... but request for repository list is the same ... only empty lis

 

date: Fri, 21 Mar 2025 10:30:14 GMT - 11:30:14 CET
server: AtlassianEdge
vary: Authorization, Origin, Accept-Encoding
x-view-name: bitbucket.apps.repo2.api.v20.repo.RepositoriesHandler
x-used-mesh: False
x-dc-location: Micros-3
x-served-by: 1d20aca91c5f
x-version: ff05a03a9359
x-static-version: ff05a03a9359
x-request-count: 3432
x-render-time: 0.05171990394592285
x-b3-traceid: 8ba8c0dcc4924e18bd41dfd7a85e180e
x-b3-spanid: 1a5bb6f7583c9680
x-usage-user-time: 0.035563
x-usage-system-time: 0.000909
x-usage-input-ops: 0
x-usage-output-ops: 0
atl-traceid: 8ba8c0dcc4924e18bd41dfd7a85e180e
atl-request-id: 8ba8c0dc-c492-4e18-bd41-dfd7a85e180e

 

I'd be happy for any idea why this isn't working.

Kind Regards

Lukas

 

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 21, 2025

Hi Lukas,

Thank you for the info. I was able to find these API calls in our logs based on the trace id.

I can see that both calls try to get the repos of the workspace you are an admin of. However, I don't see any authentication details and I also can't see what kind of client you are using. The status code of both calls is 304.

  1. How are you running this API call? Do you use an API GUI client? Have you written a script yourself?
  2. What kind of headers are you using with the API call?
  3. If you haven't tried running the API call with curl, could you please try it from a terminal application with the command below, and let me know if you can get the repos this way? You just need to have curl installed on the machine where you run it.
    curl -v -u username:app_password --request GET \
    --url 'https://api.bitbucket.org/2.0/repositories/workspace-id' \
    --header 'Accept: application/json'

Kind regards,
Theodora

lukas_kubicek March 21, 2025

Hi,

well I was using REST client ... Thank you for your advice ... I had to change curl version and finally could be able to receive access token and successfully use it in repo. request.

So I guess problem was in my REST client and version of curl. .. Now it works as expected..

 

Thank you very much for your help :-)

Lukas

 

Like Theodora Boudale likes this
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 21, 2025

Thank you for the update, Lukas. It's good to hear that it worked!

Please feel free to reach out if you ever need anything else!

Suggest an answer

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

Atlassian Community Events