I'm trying to perform a POST HTTP request using C++ REST SDK (Casablanca) library, but I'm not succeeding... Nor I can find any recent/working snippet. Can anybody help me?
With my following code I obtain a runtime web::json::json_exception saying "not a string":
json::value postData;
postData[L"name"] = json::value::string(L"Joe Smith");
postData[L"sport"] = json::value::string(L"Baseball");
web::http::client::http_client client(L"https://jsonplaceholder.typicode.com/posts");
try
{
client.request(
methods::POST,
L"",
postData/*.as_string().c_str()*/,
L"application/json");
}
catch (web::json::json_exception &je)
{
std::cout << je.what();
}
catch (std::exception &e)
{
std::cout << e.what();
}