Re: [racket-users] Sending RESTful Commands using Racket

2015-06-19 Thread antoine
Hello, Use (define-values (a b c) (http-send-recv ...)) as a remplacement for define when you receive multiple values. Or (let-values ([(a b c) (http-send-recv ...)]) ...) the same idea but for let. You can search for binding ending with '-values'. see http://docs.racket-lang.org/reference/eva

Re: [racket-users] Sending RESTful Commands using Racket

2015-06-19 Thread brucehs
Hi Jay, Sorry for this newbie question, but how do I grab just the third value. Everything I try gets me an arity mismatch: result arity mismatch; expected number of values not received expected: 1 received: 3 values...: #"HTTP/1.1 200 OK" '(#"Cache-Control: no-store, no-cache, must

Re: [racket-users] Sending RESTful Commands using Racket

2015-06-17 Thread Michael Wilber
If you're on linux, one dirty trick you could try is to start up a local "web server" like netcat to just listen on the HTTP port and show you the request that's happening: nc -l -p 80 Then, point Curl and your Racket script to localhost and compare the request sent by each. bruc...@gmail.co

Re: [racket-users] Sending RESTful Commands using Racket

2015-06-17 Thread Jay McCarthy
The http-sendrecv function returns three values: status : bytes? header : (listof bytes?) response : input-port? You need to look at the third one for the response. You could pass it to read-json or you could do port->string or anything else that you can do with an input port. Jay On Wed, Jun

Re: [racket-users] Sending RESTful Commands using Racket

2015-06-17 Thread brucehs
John, Thank you so much. That solved the problem of controlling the lights. However, I still can't figure out how to get at the response from the Hue Bridge. I should be receiving: [ {"success":{"/lights/1/state/on":true}}, {"success":{"/lights/1/state/bri":170}}, {"succ

Re: [racket-users] Sending RESTful Commands using Racket

2015-06-17 Thread 'John Clements' via Racket Users
> On Jun 17, 2015, at 11:38 AM, bruc...@gmail.com wrote: > > Thanks so much; however, I'm still having trouble getting the lights to > respond. I had to alter your example somewhat, because Racket was complaining > about an "in-string: contract violation". The following seems to work: Oops for

Re: [racket-users] Sending RESTful Commands using Racket

2015-06-17 Thread brucehs
Thanks so much; however, I'm still having trouble getting the lights to respond. I had to alter your example somewhat, because Racket was complaining about an "in-string: contract violation". The following seems to work: (http-sendrecv "192.168.1.95" "/api//lights/1/state" #:method 'PUT #:dat

Re: [racket-users] Sending RESTful Commands using Racket

2015-06-17 Thread 'John Clements' via Racket Users
> On Jun 17, 2015, at 8:35 AM, Alexis King wrote: > > You probably want to use the net/http-client library, specifically the > http-sendrecv function. I’m not 100% sure, but I’d guess that the equivalent > Racket code for your curl command would look something like this. > > (require net/http

Re: [racket-users] Sending RESTful Commands using Racket

2015-06-17 Thread Alexis King
You probably want to use the net/http-client library, specifically the http-sendrecv function. I’m not 100% sure, but I’d guess that the equivalent Racket code for your curl command would look something like this. (require net/http-client net/uri-codec) (http-sendrecv "192.168.1.20" "