[ANSWERED]: Can't use CURL

Posted on
Tue Dec 09, 2014 3:26 pm
vasisht offline
Posts: 36
Joined: Dec 08, 2012

[ANSWERED]: Can't use CURL

So after a lot of searching, I finally found out how to make curl work with passwords. The first time I tried this:

curl -u user:pass --anyauth -X PUT -d brightness=100 http://localhost:8176/Master\ Bedroom\ Lights

My bedroom lights turned on with a brightness of 100%. Perfect.

Then I tried this:

curl -u user:pass --anyauth -X PUT -d brightness=25 http://localhost:8176/Master\ Bedroom\ Lights

And nothing happens.

Nothing happens when I try -d turnOn-1, turnOff=1, etc....

However, if I open Safari, and go to http://localhost:8176/Master%20Bedroom% ... t&turnOn=1 it works every time
All other variations work fine if I use the web address in safari, but curl refuses to work.

Does anyone have ideas?

Thanks!

Posted on
Wed Dec 10, 2014 10:08 am
matt (support) offline
Site Admin
User avatar
Posts: 20613
Joined: Jan 27, 2003
Location: Texas

Re: Can't use CURL

So the first example worked but not the second, and the only difference was the brightness value change from 100 to 25?

What does the Indigo Event Log show?

I doubt this is the problem, but instead of --anyauth use --digest.

Image

Posted on
Wed Dec 10, 2014 11:51 am
achterberg offline
Posts: 93
Joined: Feb 22, 2005
Location: Texas

Re: [ANSWERED]: Can't use CURL

Doesn't "devices" need to be in the request?
curl -u user:pass --anyauth -X PUT -d brightness=100 http://localhost:8176/devices/Master\ Bedroom\ Lights

That said, if issued in sequence:
curl -u user:pass --anyauth -X PUT -d isOn=1 http://localhost:8176/devices/Bed\ Lamp -- turns on light
curl -u user:pass --anyauth -X PUT -d isOn=0 http://localhost:8176/devices/Bed\ Lamp -- returns prompt

Posted on
Wed Dec 10, 2014 1:10 pm
RogueProeliator offline
User avatar
Posts: 2440
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: [ANSWERED]: Can't use CURL

curl -u user:pass --anyauth -X PUT -d brightness=100 http://localhost:8176/Master\ Bedroom\ Lights

You may have a couple of issues here... try fixing these and giving it another try (I don't know which of these is required/lenient but I would change all to have the best chance of success):
  • Probably should specify the authentication (--digest as Matt suggested is the default for Indigo)
  • You are missing the /devices/ directory (at least compared to my installation)
  • I don't believe that the slash-space escape it proper here as cURL is expecting a URL-escaped string; your spaces should be %20 instead
  • Add the .txt extension to the filename

Code: Select all
curl -u user:pass --digest -X PUT -d brightness=100 http://localhost:8176/devices/Master%20Bedroom%20Lights.txt

Adam

Posted on
Thu Dec 11, 2014 9:25 am
vasisht offline
Posts: 36
Joined: Dec 08, 2012

Re: [ANSWERED]: Can't use CURL

Looks like that all fixed it. I had the missing "devices" and I had to switch the escaped spaces with %20 (which oddly enough didn't work the first time for whatever reason). --anyauth works, but if --digest is the better way I'll just use that. Adding the .txt at the end didn't seem to make a difference.

Thanks for the help, all

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests

cron