Failed creating variable through railway API

andremaytorena
PROOP

6 months ago

I am trying to update an environment variable using the railway api, I don't really know how the API works since I've never used graphql, I ended up with this code but I get status 400:

import json

import requests

url = 'https://backboard.railway.com/graphql/v2'

headers = {

'Project-Access-Token': 'PROJECT_ACCESS_TOKEN',

'Content-Type': 'application/json',

}

payload = {

"query": """

mutation {

variableUpsert(

projectId: "PROJECT_ID",

environmentId: "ENVIRONMENT_ID",

serviceId: "SERVICE_ID",

name: "NEW_VARIABLE",

value: "SECRET_VALUE"

)

}

"""

}

resp = requests.post(url, headers=headers, json=payload)

# 4) Check the result

try:

resp.raise_for_status()

print(" Upserted:", resp.json())

except requests.exceptions.HTTPError:

print("HTTP", resp.status_code)

print(resp.text)```

Closed

1 Replies

6 months ago

Hello,

Please do not open duplicate threads.


Status changed to Awaiting User Response Railway 7 months ago


Status changed to Closed brody 7 months ago


Loading...