Update Repo Variable returning 404 #186505
-
Select Topic AreaQuestion BodyWe have a build task and we use the update repo varriable Rest Api endpoint to update a variable. This was working fine earlier but now its goving me 404.
What are the possible reasons? Documentation does not have error details. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Hello! Seeing a Since your build process hasn't changed but the result has, here are the most likely reasons for this failure: 1. Token Expiration or Scope ChangeThis is the #1 culprit. If you are using a Personal Access Token (PAT), it may have expired or had its scopes modified.
2. The Variable Name is Case-SensitiveGitHub Actions variables are case-sensitive in the API. If your build script recently changed 3. Repository Renaming or TransferDid the repository or the Organization name change recently? If the repo was moved or renamed, the old URL might redirect for
4. Base64 or Special Character EncodingIf your
5. "Variables" vs "Secrets"Double-check that you are hitting the Recommended Debug Step: |
Beta Was this translation helpful? Give feedback.
-
|
One thing worth adding to what's been said: if this is running inside a GitHub Actions workflow using the default For fine-grained PATs, the specific permission you need is "Variables" (Read and Write) under Repository permissions. It's easy to miss because it's separate from the general Quick way to isolate the issue: run the call manually from your local machine: curl -X PATCH \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"value":"test123"}' \
https://api.github.com/repos/{owner}/{repo}/actions/variables/{variable_name}If that returns 404 locally, the token is the problem. If it works locally but fails in CI, the workflow is using a different token than you think (check if you're accidentally reading the token from a secret that expired or was rotated). Also worth double-checking the variable name casing since the API is case-sensitive. |
Beta Was this translation helpful? Give feedback.

One thing worth adding to what's been said: if this is running inside a GitHub Actions workflow using the default
GITHUB_TOKEN, that token can't update repository variables regardless of scopes. Updating variables via the API from within a workflow requires a PAT or a GitHub App token with the right permissions.For fine-grained PATs, the specific permission you need is "Variables" (Read and Write) under Repository permissions. It's easy to miss because it's separate from the general
actionsscope.Quick way to isolate the issue: run the call manually from your local machine: