Hi
I can issue a post action with success but body arrives to rest server as text and then is not well interpreted. I need to send body as json. I did
...
const char *post_data = "{\"channel\":\"A\",\"value\":\"X\"}";
esp_http_client_set_method(client, HTTP_METHOD_POST);
esp_http_client_set_post_field(client, post_data, strlen(post_data));
//esp_http_client_set_header(client, "Content-Type", "application/json");
esp_err_t err = esp_http_client_perform(client);
...
This works but post_data is sent as text. If I use
...
const char *post_data = "{\"channel\":\"A\",\"value\":\"X\"}";
esp_http_client_set_method(client, HTTP_METHOD_POST);
esp_http_client_set_post_field(client, post_data, strlen(post_data));
esp_http_client_set_header(client, "Content-Type", "application/json");
esp_err_t err = esp_http_client_perform(client);
...
I see:
Guru Meditation Error: Core 0 panic'ed (LoadProhibited)
. Exception was unhandled.
Why?
In my mind it seems that a a json parser is missing?! I dont know... post_data is already json... Do I need a json parser. If so, I dont hvae any idea how to configure it.
Help please...
esp_http_client: how to post using json?
Re: esp_http_client: how to post using json?
Could you use make monitor and paste full backtace?
Re: esp_http_client: how to post using json?
Finally "done"...
I was creating a destroying all the rest things per request. o, the first run well but the other ones do not .
Now, recycling all the things and changing only the post data, it works...
Thanks a lot
I was creating a destroying all the rest things per request. o, the first run well but the other ones do not .
Now, recycling all the things and changing only the post data, it works...
Thanks a lot
Re: esp_http_client: how to post using json?
Hi, Imovit,
I met the same problem , could you paste the code for a sample?thank you very much!
I met the same problem , could you paste the code for a sample?thank you very much!
Who is online
Users browsing this forum: No registered users and 105 guests