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

New Post: HTTP API Help

$
0
0
Hi Matt,

The http_client tutorial is actually quite short code wise and basically just walks through setting up the C++ Rest SDK and making a simple HTTP GET request. It sounds like that is what you want to do as well. I think you just need to create a http_client for the base portion of your URI and then make each of the requests and then decide what to do with the data. Probably looking something like this:
    uri address(U("http://10.180.90.171:8080/api/"));
    http_client client(address);
    std::vector<pplx::task<void>> requests;

    // Function=Cut
    requests.push_back(client.request(methods::GET, uri_builder(address).append_query(U("Function"), U("Cut")).to_string())
        .then([](http_response response)
    {
        // TODO check response.status_code() and handle any data...
    }));

    // Function=Fade
    requests.push_back(client.request(methods::GET, uri_builder(address).append_query(U("Function"), U("Fade")).to_string())
        .then([](http_response response)
    {
        // TODO check response.status_code() and handle any data...
    }));

    // Function=Zoom
    requests.push_back(client.request(methods::GET, uri_builder(address).append_query(U("Function"), U("Zoom")).to_string())
        .then([](http_response response)
    {
        // TODO check response.status_code() and handle any data...
    }));

    // Wait for all the requests to be processed and handle any exceptions.
    ::pplx::when_all(requests.begin(), requests.end()).then([](::pplx::task<void> t)
    {
        try
        {
            t.get();
        }
        catch (const http_exception &e)
        {
            // TODO handle exceptions...
        }
    });
Steve

Viewing all articles
Browse latest Browse all 4845

Trending Articles



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