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 client " Winhttpsend request error"

$
0
0
This is the code for which I am getting a Winhttpsend request error . Some of the community members have experienced similar issue and have resolved it . Kindly let me know your inputs
    //set credentials
    http_client_config config1;
    printf("3");
    credentials cred = credentials(U("admin"), U("admin"));
    printf("4");
    config1.set_credentials(cred);
    //set method        
    // ## http_client ## Use http_client to create a connection to HTTP service
    // The client constructor either accepts a string or a URI 
    printf("5");
    http_client session(U("https://10.11.1.152:9440"), config1);
    printf("6");
    http_request request;
    printf("7");
    //set method
    request.set_method(methods::GET);
    printf("8");
    //  ## URI ## - Uniform request identifiers that are used for defining entities based on the context . In the case of HTTPS and REST , URI will be used to
    // identify the protocol , the server , port , parameters 
    // URI format --- > protocol : // server [: port] / path ? query # fragment 
    // Example web::uri_builder builder;          
    // Example builder.set_query(U("key1=val1"));
    // Example builder.set_fragment(U("last"));
    // Example uri_builder builder(U("https://10.11.1.152:9440/"));
    // Exampke builder.set_path(U("PrismGateway/services/rest/v1/protection_domains/snapshots/"));
    request.set_request_uri(uri(U("/PrismGateway/services/rest/v1/protection_domains/snapshots/")));
    printf("9");
    //request.set_body("application/json"); - To be used only for PUT
    printf("10");
        // Wait for all the outstanding I/O to complete and handle any exceptions
    try
    {
        printf("10");
        http_response response = session.request(request).get();
        printf("Received response status code:%u\n", response.status_code());
        printf("12");
    }
    catch (std::exception& e)
    {
        printf(e.what());
    } 
    }

Viewing all articles
Browse latest Browse all 4845

Trending Articles



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