I see this blog, but it refers to a specific repository variable. I however, want to create/update a workspace variable. Will it be the same --data, but the URL will stop at the workspace?
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pipelines/#api-repositories-workspace-repo-slug-pipelines-config-variables-variable-uuid-put
Hey @Chris Fouts ,
thanks for reaching out to Community!
The endpoint to update workspace variables and repository variables is a little bit different:
PUT https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pipelines_config/variables/{variable_uuid}
PUT https://api.bitbucket.org/2.0/workspaces/{workspace}/pipelines-config/variables/{variable_uuid}
While the endpoints are different, the request body (--data) is the same amongst those two endpoints.
I hope that helps! Should you have any questions, feel free to ask.
Thank you, @Chris Fouts !
Patrik S
Thanks @Patrik S I was able to create a workspace variable per you answer. However, I can't update it, and get no discernable error. I get the variable_uuid by
GET https://api.bitbucket.org/2.0/workspaces/{workspace}/pipelines-config/variables?page=2
and see
{ "type": "pipeline_variable", "uuid": "{f8278c5e-b42b-4fc7-8a47-d3bbb8f98808}", "key": "TEST_VAR", "value": "TEST_VALUE", "secured": false, "system": false, "scope": "ACCOUNT" },
So I do a
PUT https://api.bitbucket.org/2.0/workspaces/{workspace}/pipelines-config/variables/{f8278c5e-b42b-4fc7-8a47-d3bbb8f98808} \ --data '{ "key": "TEST_VAR", "value: "NEW_VALUE", "secured: false }'
I opened a Bitbucket support ticket too where I give more information that I can't put here.
I noticed you opened a support ticket but set it as resolved already.
I'll be sharing the same response here so it may be useful for other users that come across the same issue.
To update a workspace, you can use a request similar to the below:
curl --location --globoff --request PUT 'https://api.bitbucket.org/2.0/workspaces/WORKSPACE/pipelines-config/variables/{VARIABLE UUID}' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <TOKEN>' \ --data '{ "key": "TEST_VAR", "value": "TEST_VALUE2", "secured": false }'
This assumes you're using a workspace access token for authentication, that has at least the "Edit variables" scope.
Could you try making a request based on the example above and let us know how it goes?
Patrik
It looks like you're new here. Sign in or register to get started.