1

I am sending a message to a web api call every xx seconds. I could not get it to work at all until I changed the header from HTTP 1.1 which is what I was using to HTTP 1.0. Then, it started working. Why would this affect things where I could not post and now I can?

This is what it was when it wasn't working:

client.println("POST /BoxLevel/api/BoxMeasurement HTTP/1.1");

And the change that fixed it:

client.println("POST /BoxLevel/api/BoxMeasurement HTTP/1.0");

Thanks!

Michael Bedford
  • 127
  • 1
  • 6

1 Answers1

1

HTTP/1.1 requires you to provide the host name of the server. And it will keep the connection open for some time unless you explicitly opt out of this. Thus, the equivalent of the basic HTTP/1.0 request in HTTP/1.1 language is

POST /the_uri HTTP/1.1
Host: foo.example.com
Connection: close
Edgar Bonet
  • 45,094
  • 4
  • 42
  • 81