我有以下代码可以发送 POST,但即使编译正确,我也会收到错误消息
http_client client(U("http://l0.71.103.63:34568"));
json::value postData;
postData["name"] = json::value::string(U("Mohammad"));
http_response response = client.request(methods::POST,postData.to_string().c_str()).get();
if(response.status_code() == status_codes::OK)
{
auto body = response.extract_string();
std::wcout << L"Added new Id: " << body.get().c_str() << std::endl;
return std::stoi(body.get().c_str());
}
但是尝试运行程序时出现以下错误
terminate called after throwing an instance of 'web::uri_exception'
what(): provided uri is invalid: {"name":"Mohammad"}
Aborted (core dumped)