Get UUID of all variables of repository
Asked by Satya Kesanakurty:

I need to get the UUID of all repository variables which is possible only through Bitbucket rest api. The requirement of this is I need to update variables using a script for which variable's UUID is must.

Here is my curl request:

curl --header 'Authorization: Bearer \<access-token\>' --header 'Accept: application/json' --url <https://api.bitbucket.org/2.0/repositories/>\<workspace-name\>/\<repo-slug\>/pipelines_config/variables/

"List Variables for a repository" API is giving values only for some variables. For the other variables, it is giving a next token.

Using next token, I am not able to list the other values. Here is how I tried:

curl --header 'Authorization: Bearer \<access-token\>' --header 'Accept: application/json' --url \<next-token\>

I am getting errors when trying to do it:

\`\`\`

\<HTML\>\<HEAD\>\<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"\>  
\<TITLE\>ERROR: The request could not be satisfied\</TITLE\>  
\</HEAD\>\<BODY\>  
\<H1\>403 ERROR\</H1\>  
\<H2\>The request could not be satisfied.\</H2\>  
\<HR noshade size="1px"\>  
Bad request.  
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.  
\<BR clear="all"\>  
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.  
\<BR clear="all"\>  
\<HR noshade size="1px"\>  
\<PRE\>  
Generated by cloudfront (CloudFront)  
Request ID: some-id  
\</PRE\>  
\<ADDRESS\>  
\</ADDRESS\>  
\</BODY\>\</HTML\>

\`\`\`

Not sure why there isn't any proper documentation for these type of actions in Bitbucket. Bitbucket documentation is not clear at all.

Please help me with this.

Thanks in advance!


Answers:
author: Ben
body: Hi Satya,

You can use the pagelen parameter to increase the output that is displayed in a single page, for example:

```
https://api.bitbucket.org/2.0/repositories/<workspaceID>/<reposlug>/pipelines_config/variables?pagelen=100
```

If there is still another page of results, you can add the page parameter to display these results:

```
https://api.bitbucket.org/2.0/repositories/<workspaceID>/<reposlug>/pipelines_config/variables?page=2
```

I hope this helps.

Cheers!

- Ben (Bitbucket Cloud Support)

comments: author: Satya Kesanakurty
body: Hi Ben!!  

Thank you very much for your help.

It works.

Thanks!!


author: Surendhiran Balaguru
body: Hi Ben,  

is there any way to get the uuid for deployment_config/variables through python  

[https://api.bitbucket.org/2.0/repositories/\<worksace_id\>/](https://api.bitbucket.org/2.0/repositories/elementsolutions/){REPO_SLUG}/deployments_config/environments/

I wanted to get the deployment values UUID and then need to update few of the existing values  

<br />


author: Shashank Sharma
body: [@Ben](/t5/user/viewprofilepage/user-id/4537226) I am running this command but no luck   
- curl --user name:Pass--header 'Accept:application/json' --url <https://api.bitbucket.org/2.0/repositories/name/repoSlug/pipelines_config/variables?pagelen=100> -H 'Content-Type:application/json'  

Getting this error:  
{"type": "error", "error": {"message": "Resource not found"}}  
I tried on another project and was able to see the results

comments: author: Ben
body: Hi [@Shashank Sharma](/t5/user/viewprofilepage/user-id/5538251)

Can you try this? I've tested on my own repository and it works without issues:

```
curl --request GET \
  --url 'https://api.bitbucket.org/2.0/repositories/workspaceID/repositoryslug/pipelines_config/variables?pagelen=100' \
  --user username:AppPassword
```

Cheers!

- Ben (Bitbucket Cloud Support)


author: Shashank Sharma
body: Hey [@Ben](/t5/user/viewprofilepage/user-id/4537226) getting the following response although I have admin access to the repo and has provided all possible permissions to the Access token as well still no luck

<br />

![Screenshot 2024-07-11 120005.png](https://community.atlassian.com/t5/image/serverpage/image-id/334939i7E542795E8C6BD65/image-size/large?v=v2&px=999 "Screenshot 2024-07-11 120005.png")


author: Shashank Sharma
body: I found the issue it was my access issue got elevated access to run the command Thanks [@Ben](/t5/user/viewprofilepage/user-id/977814)


Tags: api

bitbucket-cloud

cloud