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.begin("http://localhost:5000/api/users/5b1e82fb8c620238a85646fc/arduinos/5b243dc666c18a2e10eb4097/data");
   http.addHeader("Content-Type", "text/plain");
   http.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjViMWU4MmZiOGM2MjAyMzhhODU2NDZmYyIsImlhdCI6MTUyOTEwMTc5MiwiZXhwIjoxNTI5MTE2MTkyfQ.2O6knqriuFoEW9C2JQKRlM3D0DNnzqC7e7gpidy3pWU");
http.end();

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:

{
"value":101
}

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

Thanks in advance.

Hallo,
this is the answer:

http.begin(“http://iot-my.herokuapp.com/api/user/ 2E 84 53 63/increment_points”);
http.addHeader(“Content-Type”, “application/json”);
int httpCode = http.POST(“JSON”);
http.end();