ESP8266 and an ASMX web service

I've written an ASMX web service to log temp/humidity data and am trying to get my ESP8266 to connect and send that data. It doesn't need to get any data as that will be consumed by an android app that I'll write later.

The service can be manually used by doing:

http://urlhere.com/TemperatureData/TemperatureData.asmx/PostTempData?Key=XXXXX&MAC=XXXXX&Temp=##.#&Humidity=##.#

I have no problem doing that local or remotely, but I'm having no luck getting the NodeMCU to send that. I've tried a number of different examples and haven't found any that are really what I need. Mostly because I'm NOT a web guy. I don't know if there are headers I need to send, or anything like that I'm guessing. I know it's connecting to the site fine (in some examples) but it never sends anything, or errors out if it does.

    String httpstring = "http://MyURL.com/TemperatureData/TemperatureData.asmx/PostTempData?Key=T8GNS68SN19ASDVBXT&MAC=";
    httpstring = httpstring + WiFi.macAddress();
    httpstring = httpstring + "&Temp=" + f + "&Humidity=" + h;

    HTTPClient http;

    http.begin(httpstring);

    http.addHeader("Content-Type", "text/plain");

    int httpCode = http.POST("");

    String payload = http.getString();
    http.end();

    Serial.println(payload);

There's a snippet of one that was throwing an error about content length. But I'm guessing I am not doing it correctly to begin with.

Any help would be appreciated.

It would appear that you do not understand the difference between a GET request, where all the data goes in the URL and a POST request, where some of the data is sent separately.

The first thing you need to determine is whether the ASMX service expects you to make a GET request or a POST request.

The second thing to do is to make the proper type of request.

Well that gives me SOMETHING to go on apparently. Thanks. :slight_smile:

Coulda just said to change your .POST to .GET though. (ok, and get rid of the header line as well but...) :smiley:

kanati8869:
Coulda just said to change your .POST to .GET though. (ok, and get rid of the header line as well but...) :smiley:

Why would I say that if the ASMX service expected you to make a POST request?