Alpaca Traders API Unable to Connect with httplib

  alpacajs, api, c++, connection, http

I am attempting to use the C++ wrapper for the Alpaca Traders API for the found here:

However, I’m having trouble even connecting to my paper trading account.

Here is the code from the wrapper for getting the Alpaca account:

httplib::Headers headers(const Environment& environment) {
  return {
      {"APCA-API-KEY-ID", environment.getAPIKeyID()},
      {"APCA-API-SECRET-KEY", environment.getAPISecretKey()},

std::pair<Status, Account> Client::getAccount() const {
  Account account;

  httplib::SSLClient client(environment_.getAPIBaseURL());
  auto resp = client.Get("/v2/account", headers(environment_));
  if (!resp) {
    return std::make_pair(Status(1, "Call to /v2/account returned an empty response"), account);

The problem is that I get an error back that it’s unable to connect:

Error: resp.error(): Connection (2)

I’ve checked the environment, and it’s been parsed correctly, I even tried the following curl command, and it was able to get the http page.

curl -X GET    -H "APCA-API-KEY-ID: {YOUR_API_KEY_ID}"    

So my machine can find, and get the page, thus it must be something in the code that is wrong. Any help would be appreciated.

Source: Windows Questions C++