Cannot make a POST request

kelapuress12
Posts: 1
Joined: Mon Jun 17, 2024 10:14 am

Cannot make a POST request

Postby kelapuress12 » 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.

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);
  
I only get output to be as
I (23777) test: HTTP_EVENT_ON_CONNECTED
The code doesn't return from `esp_err_t err = esp_http_client_perform(client);` at all.

What could be going wrong?

NOTE: I have set
CONFIG_ESP_TLS_INSECURE=y
CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=y
in sdkconfig
and I am using ESP_IDF v5.1

Who is online

Users browsing this forum: No registered users and 80 guests