Go Down

Topic: HTTP client is giving wrong results.. (Read 1 time) previous topic - next topic

maimi

Jun 12, 2014, 05:52 pm Last Edit: Jun 12, 2014, 06:56 pm by maimi Reason: 1
hello there,

I have a java server on local host, that sets the status of LCD either 0 or 1.
the resource URI is: http://localhost/mytrain/restserver/train/lcd
and the content of the page is: {"lcdStatus": 0} or {"lcdStatus":1}

I'm trying to make my Arduino HTTP client reads it, and depending on the value 0 or 1 to control an LCD.
But it's not working.. When it gives an answer, then it's ΓΏ

Could anyone please help me here? what should I write in the GET request?
My Arduino is Mega 2560, with Ethernet shield

thanks in advance

robtillaart

post your code

localhost = 127.0.0.1  is an internal loopback device address,
you must use the external NIC number, e.g. 192.168.1.10

http://192.168.1.10/mytrain/restserver/train/lcd

give it a try
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

maimi

thanks, you're right.. However I must enter credentials, user name and password.. How to do this in Arduino code?

robtillaart

#3
Jun 13, 2014, 05:27 pm Last Edit: Jun 13, 2014, 05:29 pm by robtillaart Reason: 1
carefully?

Google for POST (although it can need another protocol)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

maimi

thanks! great idea! didn't know that one could use POST in Arduino!
I found this.. http://forum.arduino.cc/index.php?topic=155218.0
I'll see how I can use it in my code..

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy