Pushing Data to server (https) in json format

Am facing difficulty in integrating the hardware running on Electron to my software hosted on AWS. I tried sending the data in json format to my domain with the specific URL path but it doesnt hit the server. This is the code snippet which i used for the integration. I came to know that Particle OS doesnt have a native https support so i changed my aws server settings to http and tried to send data with the same code with port being changed to 80. But that too didnt hit the server.
Can anyone help me out in resolving this issue.Am not that good at coding so pardon me for the below code snippet.
Am looking forward for solutions that could send data to my server with secure communication i.e https . I did use the weebhooks and it worked but am trying to bring the the whole thing in the code itself because am developing a product and i cant keep creating webhooks for each device when scaling up.

String jsonDataString =String("{\"A\":\"57051\",\"B\":\"30808\",\"C\":\"37.98\",\"D\":\"1.029\",\"E\":\"8.54\",\"F\":\"300.6\",\"G\":\"8.915\",\"H\":\"42.31\"}");
if (client.connect(server, 80))
{
   Serial.println("Connected to server");
   client.println("POST");
   client.println(urlPath);
   client.println("HTTP/1.1");
   client.print("Host: ");
   client.println(server);
   client.println("Cache-Control: no-cache");
   client.println("content-type: application/json");
   client.print("content-length: ");
   client.println(strlen(jsonDataString));
   client.println();
   client.println(jsonDataString);
   client.println();
   client.stop();
}

Thanks for you support in advance.

This may not be your issue but I noticed that this JSON

is invalid - test it using JSONLint.

This version of the JSON string works ...

{
	"A": "57051",
	"B": "30808",
	"C": "37.98",
	"D": "1.029",
	"E": "8.54",
	"F": "300.6",
	"G": "8.915",
	"H": "42.31"
}

General advice is to avoid using string object as well.

Better to format a c string array using snprintf() like this:

char dataStr[600];
snprintf(dataStr, sizeof(dataStr), "{\"A\":\"%i\"}", varA);

Also you need to escape the " character.

@armor, I replaced your typographic double quotes ( & ) with normal ones (") and also corrected the escaping from forward slash (/") to backslash (\")

BTW, the OP had that escaped correctly already - Discourse just didn't show it that way :face_with_raised_eyebrow:

@shanevanj, I can't really see anything wrong with his JSON (apart from the typographic double quotes that were replaced by Discourse - this forum software - since the code block wasn't wrapped in ``` correctly - I changed that).

@SushilPaul, it would be interesting to see how you declared your server.

With this (fully functional) code I can hit my test server just fine

TCPClient client;
IPAddress server( 192, 168, 1, 1 );
const int  port = 8080;  // mobile AP won't allow the test server on 80
const char *urlPath = "/somePath";

void setup() {

}

void loop() {
  // hit MODE/SETUP button to send 
  if (!digitalRead(BTN)) {
    while(digitalRead(BTN));
    const char* jsonDataString = "{\"A\":\"57051\",\"B\":\"30808\",\"C\":\"37.98\",\"D\":\"1.029\",\"E\":\"8.54\",\"F\":\"300.6\",\"G\":\"8.915\",\"H\":\"42.31\"}";
    if (client.connect(server, port))
    {
      Serial.println("Connected to server");
      client.println("POST");
      client.println(urlPath);
      client.println("HTTP/1.1");
      client.print("Host: ");
      client.println(server);
      client.println("Cache-Control: no-cache");
      client.println("content-type: application/json");
      client.print("content-length: ");
      client.println(strlen(jsonDataString));
      client.println();
      client.println(jsonDataString);
      client.println();
      client.stop();
    }
    delay(1000);
  }
}

Your code connects to port 80, but you state in the subject that it’s expecting HTTPS. Are you using TCPClient? If so, that will NOT work for HTTPS (TLS) connections. You’d need to use a TLS library such as TlsTcpClient by @hirotakaster.

Actually he said he changed to 80 after he realised HTTPS was no (easy) option.

Not sure if you're aware, but there is official support to group your devices into a product to simplify firmware and webhook management. You would only need to define the single webhook and it would be used by all devices in the product.

https://docs.particle.io/tutorials/device-cloud/console/#devices-vs-product-devices