Using POST method it inserts a randomkey as child. I just want "Name: Sudarshan" to be the child of UserList.
Can anyone point at what am doing wrong here.
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;
});
The POST request automatically creates a chronologically incremental key name for you. If you want a specific key name, do a PUT request instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.