HTTP Post request with JSON data on Arduino Uno Wifi


To quickly present my project: I made a simple connected alarm for my home based on an Arduino Uno Wifi and a PIR sensor. The data must be sent to my server with HTTP post request with data as JSON format (Content-Type: application/json for request header)

I've read all examples with Ciao library for Arduino Uno Wifi but it seems I can't sent data as JSON with this library...

Do you have specific library or exemple to send data as JSON in HTTP post request with Arduino Uno Wifi?

Thank you in advance!

Not tested but Something like this Using the default library

IPAddress server(192,168,1,120); // server IP address
char PostData[] = "{\"name\": \"Fred\", \"age\": 31}"; // your JSON payload


if (client.connect(server, 80)) {
  client.println("POST /doit HTTP/1.1");
  client.println("Host:"); // or generate from your server variable to not hardwire
  client.println("User-Agent: Arduino/unowifi");
  client.println("Connection: close");
  client.print("Content-Length: ");
  client.println(strlen(PostData));// number of bytes in the payload
  client.println();// important need an empty line here 
  client.println(PostData);// the payload

Hello sim254,

I have the same problem than you. The reply by J-M-L works for Wifi shield but not with Arduino unowifi because client.connect does not exist.

I have tried with ciao: CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, json);

but it is not working either as for my project I need to define in the HTTP request field: an APIkey for Carriots.

Any other idea how we can solve this issue?


Hello patatica,

No solutions with my Arduino Uno Wifi and JSON requests. I have created simple POST requests on Arduino and update requests with my Nginx proxy but not really cool solution...

Now I need to read response body from a GET request with Ciao.write but I have no content from logs... (CMD_Exec: no response (0))

If you have the solution I'm interested.

PS: I think buying a classic arduino with a separate ESP. The arduino Uno Wifi is really not a finished product :'(