0

POST メソッドを使用して、ランダムキーを子として挿入します。「Name: Sudarshan」を UserList の子にしたいだけです。

ここで間違っていることを誰でも指摘できますか。

return pplx::create_task([]
  {
    json::value postData;
    std::string MY_JSON = "{  \"Name\": \"Sudarshan\"  }";
        postData = json::value::parse(utility::conversions::to_string_t(MY_JSON)); 
    http_client client(L"xxx.firebaseio.com/users/UserList.json");
    string_t PathQueryFragment = L"";
    return client.request(methods::POST, PathQueryFragment,
             postData.to_string().c_str(),
                         L"application/json");
  }).then([](http_response response)
  {
    if(response.status_code() == status_codes::OK)
    {
      auto body = response.extract_string();  
      //return std::stoi(body.get().c_str());
    }
    return 0;
  });

画像

4

1 に答える 1

0

POST 要求は、時系列で増加するキー名を自動的に作成します。特定のキー名が必要な場合は、代わりに PUT リクエストを実行してください。

于 2014-02-11T18:23:39.507 に答える