-->
Page 1 of 1

Http get command does not work the same than with a computer

PostPosted: Mon Jan 23, 2017 12:06 am
by vdiallonort
Hello,

I am trying to send Http get to a camera ( Olympus AIR) . It work quite well from a computer : This is the wireshark trace :
Image
So its http://192.168.0.10/get_commandlist.cgi
with the following header :
Host:192.168.0.10
User-Agent:OlympusCameraKit

So my code is :
Code: Select all#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>

ESP8266WiFiMulti WiFiMulti;

void setup() {
    Serial.begin(115200);
    delay(10);
    Serial.print("Wait for WiFi... ");

    while(WiFiMulti.run() != WL_CONNECTED) {
        Serial.print(".");
        delay(500);
    }
    Serial.println("");
    Serial.println("WiFi connected");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());
    delay(500);
}

void loop() {
  HTTPClient http;
  http.begin("http://192.168.0.10/get_commandlist.cgi");
    http.addHeader("Host","192.168.0.10",true,true);
  http.addHeader("User-Agent","OlympusCameraKit");
    http.addHeader("Connection","KeepAlive"); 
  int httpCode = http.GET();
  Serial.println(httpCode);
  String payload = http.getString();
Serial.println(payload);
http.end();
delay(5000);
 
}


But the answer is 404 for Http error 404 as oppose of a xml result as i get when i do the same request from my computer.

Re: Http get command does not work the same than with a comp

PostPosted: Thu Jan 26, 2017 4:26 pm
by Amir Djavaherian
404 is simply "Not Found" so if you are getting the STATUS_CODE then perhaps your HTTP GET request from the ESP8266 is correct, but the path is wrong or the string you are using for the URL needs to be encoded properly? FAIK, The HTTP looks fine.