Hi,
I'm having problems using POST. I have no problems sending data to my channel using GET but I want to find out what I am doing wrong with POST.
I am using an Arduino connected via an ESP-07 (ESP8266) Wifi board.
I'm using basic AT commands as follows:
I connect to the internet Ok.
I then send a command to connect to ThingSpeak:
//////////////////////////////////////////////////////////////
AT+CIPSTART="TCP","184.106.153.149",80
CONNECT
OK
////////////////////////////////////////////////////////////////
This works when I use GET so the connection to the server is ok.
I then POST data as follows:
//////////////////////////////////////////////////////////////////
AT+CIPSEND=231
OK
> POST /update HTTP/1.1
Host: 184.106.153.149
Connection: close
X-THINGSPEAKAPI: XXXXXXXXXXXXXXXX
Content-Type: application/x-www-form-urlencoded
Content-Length: 58
field1=16372&field2=1328&field3=-62&field4=-62&field5=-167
SEND OK
///////////////////////////////////////////////////////////////////////////
The response that I get back is:
Response
///////////////////////////////////////////////////////////////////////////
+IPD,556:HTTP/1.1 400 Bad Request
Server: nginx/1.7.5
Date: Tue, 22 Mar 2016 20:33:13 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Status: 400 Bad Request
X-Frame-Options: ALLOWALL
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE, PATCH
Access-Control-Allow-Headers: origin, content-type, X-Requested-With
Access-Control-Max-Age: 1800
Cache-Control: no-cache
X-Request-Id: cbbf6976-0d38-4099-9d12-51c616bff413
Set-Cookie: request_method=POST; path=/
1
0
0
CLOSED
/////////////////////////////////////////////////////////////////////////////////////////////////////
I'm writing each line in turn rather than one long string.
Each line has a backslash-r-backslash-n at the end including the last line.