API call to repository details fails with UUID
Asked by Adam Leppek:

GET calls to the endpoint **/2.0/repositories/{workspace}/{repo_slug}** fail when you use a UUID for the repo slug:
> {"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."}}

The UUID is surrounded by braces as directed. The workspace is verified to be correct (the lowercase name works in other API calls). This fails whether or not a slash is used at the end of the URL.

The repo UUID was found with a call to /2.0/repositories/{workspace}, with the same user. User access to the repo was verified.

Please advise.


Answers:
author: seanaty
body: It's likely you need to percent-encode the curly brackets {} which are %7B and %7D respectively.

Without encoding:

```
% curl 'https://api.bitbucket.org/2.0/repositories/atlassian/{5137f783-a12b-4958-a614-4a2af63fca20}' | jq . 
{
  "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."
  }
}
```

With encoding:

```
% curl 'https://api.bitbucket.org/2.0/repositories/atlassian/%7B5137f783-a12b-4958-a614-4a2af63fca20%7D' | jq . 

{
  "scm": "git",
  "website": "",
  "has_wiki": false,
  "uuid": "{5137f783-a12b-4958-a614-4a2af63fca20}",
  "fork_policy": "allow_forks",
  "full_name": "atlassian/atlassian-jwt-py",
  "name": "atlassian-jwt-py",
  "project": {

    "type": "project",
    "name": "Atlassian Connect",
    "key": "AC",
    "uuid": "{cc445f42-b2f8-4d69-bfd1-4e0047966e87}"
  },
  "language": "python",
  "created_on": "2016-06-29T15:49:21.227310+00:00",
  "mainbranch": {
    "type": "branch",
    "name": "master"
  },
  "workspace": {
    "slug": "atlassian",
    "type": "workspace",
    "name": "Atlassian",
    "uuid": "{02b941e3-cfaa-40f9-9a58-cec53e20bdc3}"
  },
  "has_issues": true,
  "updated_on": "2021-10-08T06:10:03.835470+00:00",
  "size": 688349,
  "type": "repository",
  "slug": "atlassian-jwt-py",
  "is_private": false,
  "description": "JWT (JSON Web Token) encoding & decoding library for Python 2 and 3. Extends pyjwt to include\r\nAtlassian's custom QSH (query string hash) claim."
}
```

comments: author: Adam Leppek
body: [@seanaty](/t5/user/viewprofilepage/user-id/1301071) I replaced the brackets with their URL codes and everything works fine. Thanks for the help!


author: Caterina Curti
body: Hi all,  

Here is an article I recently wrote that covers UUIDs, workspace names and repository slugs when working with Bitbucket:

[Working with UUIDs and their curly brackets, workspace names or repository slugs in Bitbucket](https://community.atlassian.com/t5/Bitbucket-articles/Working-with-UUIDs-and-their-curly-brackets-workspace-names-or/ba-p/2500759)   

<br />

The file in the provided example (<https://bitbucket.org/atlassian/forge-bitbucket-assign-pr-reviewer/src/main/src/index.js>) shows how to fetch a repository with all its details given a workspace and repository UUID.

Hopefully, it provides some clarity.  

Cheers,  
Caterina


Tags: api

bitbucket-cloud

cloud