I am using libcpr for http requests in Visual Studio 2019 IDE. I downloaded it using vcpkg from microsoft. The sample code below is from cpr github page https://github.com/libcpr/cpr#:~:text=#include <,return 0; }
#include <cpr/cpr.h>
int main(int argc, char** argv) {
cpr::Response r =
cpr::Get(cpr::Url{"https://api.github.com/repos/whoshuu/cpr/contributors"},
cpr::Authentication{"user", "pass", cpr::AuthMode::BASIC},
cpr::Parameters{{"anon", "true"}, {"key", "value"}});
r.status_code; // 200
r.header["content-type"]; // application/json; charset=utf-8
r.text; // JSON text string
return 0;
}
This doesn't work! It is giving error "namespace "cpr" has no member "AuthMode". This problem is not with this only. There was some other stuff that gives similar error e.g. https://docs.libcpr.org/advanced-usage.html#https-options:~:text=cpr::SslOptions sslOpts = cpr::Ssl(ssl::CaBuffer{"-----BEGIN CERTIFICATE-----[...]"}); cpr::Response r = cpr::Get(cpr::Url{"https://www.httpbin.org/get"}, sslOpts); in this case "CaBuffer" has same issue.
Any help would be appreciated!!
Thanks
CodePudding user response:
Looks to me like a versioning issue. AuthMode
exists in the latest header file, but does not exist in the version 1.8 header file, which is presumably what you have.
So, either downgrade your code, or upgrade your installation.
Sample code from version 1.8 is here