RESTful command client error

Hello everybody!

Tried to set up a RESTful command to turn a webcams recording feature on and off (see below). As this is my first step into HA RESTful commands any help or tips would be kindly appreciated - thank you! :heart:

This here is the link to its API documentation which tells me to change the configuration taking into account:

Set configuration

http://IP_CAM/cgi-bin/set_configs.sh?conf=CONF
CONF action
system Update system configuration
(…) (…)

Need POST method with a json file.

The relevant system setting and its payload within would be:

{
…,
"REC_WITHOUT_CLOUD":"yes",
…
}

And my RESTful service is:

rest_command:
  cam_eg_surveillance_on:
    url: "http://username:[email protected]:8080/cgi-bin/set_configs.sh?conf=system"
    method: POST
    payload: "REC_WITHOUT_CLOUD=yes"
    content_type: 'application/json; charset=utf-8'
  cam_eg_surveillance_off:
    url: "http://username:[email protected]:8080/cgi-bin/set_configs.sh?conf=system"
    method: POST
    content_type: 'application/json; charset=utf-8'
    payload: "REC_WITHOUT_CLOUD=no"

But when I call the service I get only

Error: Client error occurred when calling resource "http://username:[email protected]:8080/cgi-bin/set_configs.sh?conf=system"
Result:
params:
  domain: rest_command
  service: cam_eg_surveillance_off
  service_data: {}
  target: {}
running_script: false

I’m getting the same with a request within the lan.

  • Core 2024.5.5
  • Supervisor 2024.05.1
  • Operating System 12.3
  • Frontend 20240501.1

Solution is coming!!
:partying_face:

Correct syntax must be like this:

rest_command:
  cam_eg_surveillance_on:
    url: "http://0.0.0.0/cgi-bin/set_configs.sh?conf=system"
    username: “username“
    password: “password“
    method: POST
    payload: ‘{"REC_WITHOUT_CLOUD“:“yes"}‘
    content_type: 'application/json; charset=utf-8'
  cam_eg_surveillance_off:
    url: "http://0.0.0.0/cgi-bin/set_configs.sh?conf=system"
    username: “username“
    password: “password“
    method: POST
    content_type: 'application/json; charset=utf-8'
    payload: ‘{"REC_WITHOUT_CLOUD“:“no"}‘

As you can see I pulled out the username and pass from the url and especially changed payload formatting!

Working like a charm now!

in my case I don’t have http auth on the url, I’ll try to debug what’s going on and write here my results.