r/crestron • u/guitarman181 • Mar 16 '16
Crestron - rest interface problems - thoughts?
I have a device that has a restful api. The following command works http://username:password@192.168.1.100:50001/rest/nodes/44 01 11 1/cmd/DFON This command turns an inston light ON.
I want to recreate this command in a Crestron module. I created a TCPIP/Client with a serial IO module that sends the following serial string: GET /rest/nodes/44 01 11 1/cmd/DFON HTTP/1.1\r\nAuthorization: username:password\r\n\r\n
The TPCIP/client module has the IP address of the device and port.
My serial IO string does not work. Does anyone know what I need to change or do differently to make it work?
2
u/gortosi Mar 16 '16
Is the TCP/IP client connected? It has an analog value for Status that will determine if it is connected or why it hasn't established communication.
1
u/guitarman181 Mar 16 '16
I changed it to: GET /rest/nodes/44 01 11 1/cmd/DFON HTTP/1.1\nAuthorization: username:password\n Removed the \r It is still not working.
I also tried http://192.168.1.100 instead of 192.168.1.100 in the TCPIP/Client config
1
u/guitarman181 Mar 19 '16
I am getting an active connection. The response is GMT * * but that's not the response of a successful command.
2
u/althypothesis Mar 29 '16
I believe that you cannot have spaces in the URL, try replacing "44 01 11 1" with "44%2001%2011%201"
Reference: http://stackoverflow.com/questions/497908/is-a-url-allowed-to-contain-a-space but more specifically http://www.ietf.org/rfc/rfc1738.txt
1
u/flinkazoid Mar 16 '16
You don't need the \r. \n is a cr+lf
1
u/[deleted] Apr 21 '16 edited Apr 21 '16
it might be expecting a Host: or User-Agent: header that your browser is sending and your module isn't sending.
The username:password needs to be Base64-encoded in the HTTP header.
Try sending: GET /rest/nodes/44 01 11 1/cmd/DFON HTTP/1.1\r\n Authorization: Basic base64encodedusername:password\r\n Host: 192.168.1.100\r\n User-Agent: Mozilla\r\n \r\n
Note that you need the word "Basic" after the Authorization: header declaration.