I'm trying to post a new record to my MongoDB (actual CouchDB), but it seems that I'm having problems with the format of my request.
I'm using the following code: (not showing debug and validations)
WiFiClient client;
client.connect("172.16.1.4", 5984)
String connStr = "POST /iot/ HTTP/1.1\r\n"
"Host: user:[email protected]:5984/ \r\n"
"Content-Type: application/json\r\n"
"\r\n"
"'{\"a\":1}'\r\n\r\n";
client.print(connStr);
I get this response back:
HTTP/1.1 400 Bad Request
Server: CouchDB/1.6.1 (Erlang OTP/18)
Date: Sat, 07 Oct 2017 11:57:50 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 48 Cache-Control: must-revalidate{"error":"bad_request","reason":"invalid_json"}
HTTP/1.1 400 Bad
Request Server: MochiWeb/1.0 (Any of you quaids got a smint?)
Date: Sat, 07 Oct 2017 11:57:50 GMT
Content-Length: 0
I have tried with differet json/data...
Using Linux - I have no problems:
curl -X POST user:[email protected]:5984/iot/ -H "Content-Type: application/json" -d '{"a":3}'