cpprestsdk服务器POST读取失败

问题描述

我发送了一个带有curl的json POST,但无法从服务器读取它。有什么问题吗?

void Handler::handle_post(HTTP_Request request){
    std::cout << request.to_string() << std::endl;
    auto j = json::value::object();
    request.extract_json().then([&j](pplx::task<json::value> task) {
    try{
        auto const & jvalue = task.get();
        for (auto const & e : jvalue.as_array())
        {
            if (e.is_string())
            {
                auto key = e.as_string();
                std::cout << key << std::endl;
            }
         }
    }
    catch (http_exception const & e)
        {
            std::cout << e.what() << std::endl;
            std::cout << "hi" << std::endl;
        }
    }).wait();
    request.reply(status_codes::OK);
}

卷曲:

curl -d '{"key1":"value1","key2":"value2"}' -H "Content-Type: application/json" -X POST http://localhost:10022

服务器请求:

enter image description here

如果信息不足,我将向您显示完整代码

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)