I am making a web application to host JSON data POSTed from an Arduino to be hashed and stored in a database.
I am having an issue with the POST request to the web app being sent from the Arduino but I can't put my finger on it.
The error being received:
[28/Sep/2013:15:43:01 CDT] "POST /json HTTP/1.1" 200 0
- -> /json
[2013-09-28 15:43:06] ERROR bad Request-Line `'.
[28/Sep/2013:15:43:06 CDT] "" 400 0
The Arduino POST:
if (client.connect(server, 4567)) {
Serial.println("connected");
// Make a HTTP request:
client.println("POST /json HTTP/1.1");
client.println("User-Agent: Arduino");
client.println("Host: localhost:4567");
client.print("Accept: *"); client.print("/"); client.println("*");
client.println("Content-Length: 15");
client.println("Content-Type: application/x-www-form-urlencoded");
client.println("");
client.println("{\"plot\":\"85.1\"}");
client.println("");
}
I am using Ruby with Sinatra for the web app.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<HEAD><TITLE>Bad Request</TITLE></HEAD>
<BODY>
<H1>Bad Request</H1>
bad Request-Line `'.
<HR>
<ADDRESS>
WEBrick/1.3.1 (Ruby/1.9.3/2013-06-27) at
localhost:4567
</ADDRESS>
</BODY>
</HTML>
Any help would be greatly appreciated, thanks in advance!