i'm trying to make use of my Intel Galileo Gen2 by making calls to a microsoft web api (REST service) hosted in azure as an web app but all i get is an azure 404 saying it won't find my app
the code on my arduino is the following
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
char serverName[] = "wack.azurewebsites.net";
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
while(true);
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(serverName, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /api/warning HTTP/1.0");
client.println();
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
while(true);
}
}
i tried changing the target url several times
client.println("GET wack.azurewebsites.net/api/warning HTTP/1.0");
client.println("GET api/warning HTTP/1.0");
client.println("GET /api/warning ");
client.println("GET /api/warning HTTP/1.1");
none of them work, some don't even connect however it only returns a 404 even though that URL is valid and tested throughout differnet applications even on the same network.
i have replaced the mac adress with the adress of the device and previously have confirmed that it can be reached in the network by making it a web server itself. Basically it can grab internet settings but for some reason will not connect to my rest service. Any kind of help is appreciated. Thx
The problem was not providing a host for the call. I come from a c# background and thought by initializing the HttpClient with the server address would be enough but apparently you have to provide this line
each time you make a request