Jump to content

Python PUT using only urllib2

Dujith

Having an issue with programming for a Gira Homeserver. Its a restricted device which runs python 2.7 and has urllib2 as a library i can use.

Problem is that the HUE lamps i want to control only react to PUT and will block GET for setting values.

 

So my first try was a module with:

payload={'on':False}
requests.put('http://"ip adress"/api/"api key"/lights/1/state', json=payload)

Since that was the easiest way and works :D 

But the homeserver does not have the requests lib and gave me an error.

 

Now my python coding is basic at best and i'm kinda stumped on how to do this with urllib2. Tried to search but the general consensus is to use requests :( 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×