I am trying to use the API to upgrade variables, but I am getting a 404 back from the url.
I tried to build the url myself, and got a 404.
So then I tried pulling the list of variables from the api. Finding the one I wanted to update, and grabbing the link
prepending the base url, and making a post to it. Still I get a 404.
The URL I call is https://app.terraform.io/api/v2/workspaces/ws-xxxxxx/vars/var-xxxxxx
.
Am I doing something wrong?
Is the new api not functional and I need to use the old variable api to update?
Here are the API docs for updating variables on Terraform Cloud. Note that the URL is /api/v2/vars/:variable_id
, and the request method is PATCH
, not POST
. Hope this helps!
1 Like
Okay I can do that. This is where I was getting confused because of the note at the top saying it is deprecated and move to the workspace variables api.
Important: The Variables API is deprecated and will be removed in a future release. All existing integrations with this API should transition to the Workspace Variables API.
I guess i’ll just use that until it doesn’t work anymore.
Oh! You’re absolutely right, I had missed that. Perhaps the problem you’re having with the other API call is the use of POST
vs PATCH
?
I’ll give that a shot real quick.
That was totally it. I was getting confused because of this line.
This POST endpoint requires a JSON object with the following properties as a request payload.
Even though above it says
PATCH /workspaces/:workspace_id/vars/:variable_id
Man I feel dumb.
Thank you for the help.
1 Like
Ah, thanks for pointing that out! I’ve opened a PR to fix up the typo.
1 Like