Author Topic: Help with curl  (Read 734 times)

Offline JuniorJedi

  • Full Member
  • ***
  • Posts: 112
  • Karma: +3/-1
Help with curl
« on: July 16, 2017, 12:07:13 pm »
Hi all,

Can anyone help with the following:

I want to send this:
curl -X POST -u "dev:7286f682d7d2388b61525e82eb11fd5a99" -H "Content-Type: application/json" -d " { \"model\": { \"frames\": [ { \"icon\":\"a2867\", \"text\":\"Hello\!\"} ] } }" http://192.168.1.147:8080/api/v2/device/notifications

To my Lametric device, it works perfectly from Terminal in OSX, and I have tried to wrap it in os.execute(" xxx") but it does not work there.

Any ideas?

Thanks in advance.

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6201
  • Karma: +276/-70
  • "Less is more"
Re: Help with curl
« Reply #1 on: July 16, 2017, 12:19:33 pm »
It rather depends exactly on what you did when you tried this.  My first guess would be that you came to grief over the double quotes.  Try instead:

Code: [Select]
os.execute [[curl -X POST -u "dev:7286f682d7d2388b61525e82eb11fd5a99" -H "Content-Type: application/json" -d " { \"model\": { \"frames\": [ { \"icon\":\"a2867\", \"text\":\"Hello\!\"} ] } }" http://192.168.1.147:8080/api/v2/device/notifications]]
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline JuniorJedi

  • Full Member
  • ***
  • Posts: 112
  • Karma: +3/-1
Re: Help with curl
« Reply #2 on: July 16, 2017, 12:30:42 pm »
It rather depends exactly on what you did when you tried this.  My first guess would be that you came to grief over the double quotes.  Try instead:

Genius akbooer, thank you so much - works perfectly :)

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6201
  • Karma: +276/-70
  • "Less is more"
Re: Help with curl
« Reply #3 on: July 16, 2017, 02:04:44 pm »
Happy to help!
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline piveraproject

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: Help with curl
« Reply #4 on: October 07, 2018, 06:05:13 pm »
I know I'm way late to this, and it sounds like this was already answered, but the solution that worked for me was:

os.execute('curl -X POST -k -H \'Content-type: application/json\' -d \'{\"text\":\"hello world\"}\' https://hooks.slack.com/services/AAAAAA/BBBBB/CCCCCC')