Unable to send Data collected in Bulk to ThingSpeak

I want to send sensor data collected in Bulk to ThingSpeak with esp32, but unable to do. I am posting relevant part of the code since it's very. Can anybody please guide me.

 if (client.connect(server, 80)) {
        client.println("POST /channels/1872339/bulk_update.json HTTP/1.1"); // Replace YOUR-CHANNEL-ID with your ThingSpeak channel ID
        client.println("Host: api.thingspeak.com");
        client.println("User-Agent: mw.doc.bulk-update (Arduino ESP8266)");
        client.println("Connection: close");
        client.println("Content-Type: application/json
                        {
                          "write_api_key": "CRDP069WR1UT2DVB",
                          "updates": [{
                              "delta_t": "0",
                              "field1": 100
                            },
                            {
                              "delta_t": "2",
                              "field1": "200"
                            },
                            {
                              "delta_t": "1",
                              "field1": 103
                            },
                            {
                              "delta_t": "2",
                              "field1": "23"
                            },
                            {
                              "delta_t": "1",
                              "field1": 86
                            },
                            {
                              "delta_t": "5",
                              "field1": "201"
                            }
                          ]
                        }"
                        );        
        client.println("Content-Length: "+data_length);
        client.println();
        client.println(data);
      }
      else {
        Serial.println("Failure: Failed to connect to ThingSpeak");
      }
      delay(250); //Wait to receive the response
      client.parseFloat();
      String resp = String(client.parseInt());
      Serial.println("Response code:"+resp); // Print the response code. 202 indicates that the server has accepted the response
      jsonBuffer[0] = '['; //Reinitialize the jsonBuffer for next batch of data
      jsonBuffer[1] = '\0';
      lastConnectionTime = millis(); //Update the last conenction time
}

Thanks,
Have a nice day

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.