Closed noctera closed 3 years ago
Hi!
Maybe this answer on Stackoverflow will be useful for you.
Thanks for your help.
I solved it by getting the header out of req
and parsing it into a json object
std::string body = request_t::body();
nlohmann::json jsonObj;
try
{
jsonObj = json::parse(body);
}
catch (const std::exception &e)
{
auto error = e.what();
std::cerr << e.what() << std::endl;
}
std::string username = jsonObj["username"];
std::string email = jsonObj["email"];
std::string password = jsonObj["password"];
I am programming a Rest Api right now and to make a post request handler
this is my code right now. But it is only working when I'm requesting like this
But this isn´t the way I want it. How can I manage to read the request body in my server I want to make an api call to /api/register without any parameters, but sending username, email, password in the request body
Like this