Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: Issue sending http request, no connection at all?

$
0
0
I am currently writing a small piece of code to familiarize myself with the REST SDK's JSON capabilities some more and following the JSON example in the documentation I have this:
pplx::task<void> WoWRealmCheck() {
    uri_builder uribuild(L"http://us.battle.net");
    uribuild.append_path(L"/api/realm/status");
    auto uri = uribuild.to_uri();
    http_client client(uri);
    return client.request(methods::GET)
        .then([](http_response response) -> pplx::task<json::value>
    {
        std::cout << "Received response code: " << response.status_code() << std::endl;
        if (response.status_code() == status_codes::OK)
            return response.extract_json();
        else
            return pplx::task_from_result(json::value());

    })
        .then([](pplx::task<json::value> jsonResponse)
    {
        try
        {
            const json::value& v = jsonResponse.get();
            std::cout << "Check 2\n";
        }
        catch (const web::http::http_exception& e)
        {
            std::cout << e.what();
        }
    });
};

int main() {
    std::cout << "Checking current status of all realms...\n";
    
    WoWRealmCheck();

}
The issue is the code does not even show a connection to the http client, it gets as the first return statement in the realm check function and then nothing, no message for response code or anything, it just cuts straight to the end of the run. I would love for someone to let me know what I'm doing incorrectly thank you.

Edit: I also know for sure the host I am connecting to provides data in the form of json per get request, http://blizzard.github.io/api-wow-docs/#realm-status-api is the api I am using.

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>