//Basic Authorization Setting
http_client_config config;
credentials creds(L"name", L"password");
config.set_credentials(creds);
http_client client(U("http://severip/"), config);
// create header
http_request req(methods::GET);
//// Add base64 result to header
req.headers().add(L"Authorization", L"Basic bmFtZTpwYXNzd29yZA");
req.set_request_uri(L"/_cat/master");
pplx::task<http_response> responses = client.request(req);
pplx::task<web::json::value> jvalue = responses.get().extract_json();
web::json::value v = jvalue.get();
utility::string_t jsonval = v.serialize();
wcout << jsonval << endl;
//with base64 encoding.
//bmFtZTpwYXNzd29yZA = name:password
I'm trying to set a credentials through cpprestsdk aka casablanca.
And I've recived 401 error which is failed to athenticate user, it means password error.
Any advice would be thankful.
Try to use the curl command to validate user/password quickly.