Cannot make a POST request
Posted: Mon Jun 17, 2024 10:23 am
I have been trying to make a POST request from ESP32S3 devkit board that is connected to internet, this is how I attempt it. Please let me know where I am going wrong.
I only get output to be as
What could be going wrong?
NOTE: I have set
and I am using ESP_IDF v5.1
Code: Select all
// Here _url = https://my-server.io/api/v1/put_many?id=abcd&model_id=wxyz&something=1234
esp_http_client_config_t config = {
.url = _url ,
.event_handler = _http_event_handler,
.buffer_size = 2048,
.buffer_size_tx = 2048,
};
esp_http_client_handle_t client = esp_http_client_init(&config);
esp_http_client_set_url(client, _url );
esp_http_client_set_method(client, HTTP_METHOD_POST);
esp_http_client_set_header(client, "Content-Type", "application/json");
// here _data = json data
esp_http_client_set_post_field(client, _data, strlen(_data));
esp_err_t err = esp_http_client_perform(client);
The code doesn't return from `esp_err_t err = esp_http_client_perform(client);` at all.I (23777) test: HTTP_EVENT_ON_CONNECTED
What could be going wrong?
NOTE: I have set
in sdkconfigCONFIG_ESP_TLS_INSECURE=y
CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=y
and I am using ESP_IDF v5.1