POST to REST API from my ESP8266

Hello everyone,

I've made a REST API and I'd like to do a post request to one of the endpoints from my ESP8266, but I can't manage to do so.

The code in the loop block so far:

HTTPClient http;    //Declare object of class HTTPClient

   http.addHeader("Content-Type", "text/plain");
   http.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjViMWU4MmZiOGM2MjAyMzhhODU2NDZmYyIsImlhdCI6MTUyOTEwMTc5MiwiZXhwIjoxNTI5MTE2MTkyfQ.2O6knqriuFoEW9C2JQKRlM3D0DNnzqC7e7gpidy3pWU");

The problem is that I don't know how to set the body of the request.

It should be a json with a single key called "value". For instance:


Anyone knows how to do it? Also it's probable that I should use the ip instead of "localhost".

Thanks in advance.

this is the answer:

http.begin(“ 2E 84 53 63/increment_points”);
http.addHeader(“Content-Type”, “application/json”);
int httpCode = http.POST(“JSON”);