HTTP Client, GET Request

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

Is the server accessible from the localnet, or just as localhost. localhost is a local server ip (normally 127.0.0.1) accessible only from web browsers on the server.

but I’m writing in the code:
char server= “http://localhost/mytrain/restserver/train/
and it connects to it.

however, is there any possibility to consider it a normal webpage and search in it for 0 or 1?

I just noticed, that when I give the URI in web browser, it asks me for user name and password,
how can I do this in Arduino, I mean to authenticate on the server?

maimi:
I just noticed, that when I give the URI in web browser, it asks me for user name and password,
how can I do this in Arduino, I mean to authenticate on the server?

The Arduino doesn’t have a web browser. The Arduino localhost (127.0.0.1) is the Arduino.

maimi:
but I’m writing in the code:
char server= “http://localhost/mytrain/restserver/train/
and it connects to it.

however, is there any possibility to consider it a normal webpage and search in it for 0 or 1?

I don’t know how it is connecting to itself, but at the risk of repeating myself, localhost for the Arduino is the Arduino, not your server.

You need an IP of you Java server plugged into the arduino.

mistergreen is right. Do you still have your Arduino connected to a laptop as in this thread?

If so, and the laptop is the Java server, then you should use 192.168.1.1 as the server ip.

yea, it's the same.. well, it's a little complex..
I have a java program on the ip 192.168.1.1 which reads a serial port (received by XBee), and send the received data to an REST server with Tomcat on local host , which serves a website..

I want to send the same received data to another Arduino with Ethernet to control a LCD. With sockets, it didn't work.. there were many conflicts, so I thought of sending the data to the Rest server to an URI, and to call the URI from Arduino.

I guess, so the right server IP is localhost in this situation.. Cause I'm connecting to the rest server, and not the serial java program on 192.168.1.1

what do you think?

Honestly, no clue what you just said.

A server is a server. It has an ip. Localhost is used only if you're on the server itself, not the same network.

sorry, I mixed things, I was very tired.

the server is on 192.168.1.1

the URI is : /192.168.1.1/mytrain/restserver/train/lcd

however, when I call the URI from a browser or an HTTP Client, I get asked for credentials.
how can I enter credentials with Arduino code?

What kind of credentials? like user & password?
Can you turn that off?

maimi:
how can I enter credentials with Arduino code?

It depends what sort of authentication the web site supports. There are lots of different ways, and they would need different implementations on the Arduino side.

yes, the credentials are username and password… unfortunately I can’t turn them off…they are important in a another part of the project.

You have to tell us how you're implementing the user/pass, with htaccess or other means?