I am trying to do a POST on a server using the C++ Rest SDK. It works fine if the Server is set in http, however if the server is set to https, then the code fails with this error
Error exception:EinHttpSendRequest: 12175: A security error occured
I assume that this is because of the certificate validation and to bypass it I set false to set_validate_certificates. But it still gives me the same error.
This is my code.
wstring baseUrl = L"https://167.199.104.41:8044";
http_client_config config;
config.set_validate_certificates(false);
http_client httpClient(baseUrl, config);
try
{
http_request req(methods::POST);
req.set_request_uri(L"/api/config/%5Bget%5D");
req.set_body("[\"pool/test/url/server\",\"pool/test/url/instance\"]", "application/json");
http_response httpResponse = httpClient.request(req).get();
http::status_code st = httpResponse.status_code();
if(httpResponse.status_code() == status_codes::OK)
{
wstring output = httpResponse.extract_string().get();
wcout << output << endl;
}
}
catch (const std::exception &e)
{
printf("Error exception:%s\n", e.what());
}
Please guide.
Thanks Sunil