Curl syntax help

hi, i am struggling with the curl syntax. i have got it working for calling scripts. but now i am trying to call the webostv.button to control volume on the tv

service: webostv.button
data:
  button: VOLUMEUP
  entity_id: media_player.lg_oled_c9

but this:

curl -X POST -H "Authorization: Bearer XYZ -H "Content-Type: application/json" -d "{\"service\": \"webostv.button\", \"button: VOLUMEUP\", \"entity_id\": \"media_player.lg_oled_c9\"}" http://hassioIP:8123/api/services/button

only returns a 404 :frowning:
i guess there is jsut a slight(?) mistake in the syntax. maybe sb. could have a look. thank you!

Missed a close-quote before second -H.

I assume hassioIP resolves or you’ve replaced the real IP address (pointless for private networks).

I think the URL should be this?

http://hassioIP:8123/api/services/webostv/button

image

…and I don’t believe you’ll then need the service within your JSON.

1 Like

thanks for the reply!

yes the close-quote got lost editing out the token. Real IP address is being used and works with scripts.

i tried with the amended URL you suggested but now i get

{"message":"Data should be valid JSON."}

so we’re getting closer but as i said i think sth about the json syntax is wrong
thanks nevertheless

"{\"webostv.button\": \"button: VOLUMEUP\", \"entity_id\": \"media_player.lg_oled_c9\"}" http://hassioIP:8123/api/services/webostv/button

returns 400 bad request

"{\"webostv.button\", \"button: VOLUMEUP\", \"entity_id\": \"media_player.lg_oled_c9\"}" http://hassioIP:8123/api/services/webostv/button

retuirns invalid json

Just button:, so

"{\"button\": \"VOLUMEUP\", \"entity_id\": \"media_player.lg_oled_c9\"}" http://hassioIP:8123/api/services/webostv/button
1 Like

that solved it. thank you very much. what an awesome community this is