Restart Service on Device using Remote API

#1

Hi all,

I’m trying to restart a device remotely using supervisor remote api as per:
https://www.balena.io/docs/reference/supervisor/supervisor-api/#restart-a-service-post-v2applicationsappidrestart-service

Most of the API endpoints on this page have description on how to use the same function remotely except these service related endpoints. Are these useable remotely? If so I believe the format would be:

   curl -X POST --header "Content-Type:application/json" \
--header "Authorization: Bearer <token here>" \
--data '{ "uuid" : "uuid of device", "data" : { "serviceName" : "name of service" } }' \
"https://api.balena.local/supervisor/v1/applications/{application id number}/restart-service"

I can’t see anyway to achieve this with the cli either. I have been doing this via SSH up to not but am trying to build myself some shortcut scripts. :slight_smile:

Worst case I can make script open SSH - run command and close.

Any help appreciated.

Cheers
Chris

#3

Hi,

The operation on the supervisor you are trying to run is v2/applications/{application id number}/restart-service. It seems like you are trying to run v1/applications/{application id number}/restart-service.

Can you try the following?

   curl -X POST --header "Content-Type:application/json" \
--header "Authorization: Bearer <token here>" \
--data '{ "uuid" : "uuid of device", "data" : { "serviceName" : "name of service" } }' \
"https://api.balena.local/supervisor/v2/applications/{application id number}/restart-service"

Cheers,
Andreas

#5

That works! Rookie mistake on my part.

Thanks for your help.