Hi I’m using many of the APIs successfully, but this one ‘Create a device service variable’ fails with Unauthorized.
For the same device I can create a environment variable: ‘Create a device environment variable’, read all it’s service variables, etc. I can also update / PATCH a service variable if existing.
This is my curl:
curl -X POST
“https://api.balena-cloud.com/v5/device_service_environment_variable”
-H “Content-Type: application/json”
-H “Authorization: Bearer [api token here]”
–data ‘{
“service_install”: “515211”,
“name”: “left_asset_dimension”,
“value”: “2”
}’
Help appreciated,
Thx,
Hi,
Are you using an API token for your user, or the device API key? I would expect that you can add a device_service_environment_variable
as you have done, assuming:
- the API key is for the user who owns the app/device
- the
service_install
is for the device/service you’re using
- the name is unique to the
service_install
Could you try adding it via the dashboard to make sure it works there too?
Hi Rich,
I’m using my user API token. I have no problems creating device service variables via dashboard.
Kind regards,
Anton
Good.
I would confirm the request by looking into the browsers network request history when you add the service env var via the dashboard; you should see a similar request to your cURL one and confirm the values etc. It would be good to see what works and what’s different to your cURL call
Great idea. So, I see ‘service_install_id’ - I used (service_id obtained from app service vars ). The call works now. Many thanks.
awesome - glad it’s sorted