I am building a small application which needs to do get requests to an API.
I use libcurl which works great if I provide the complete URL directly within the function, but if I do it inside of a function with the URL as a parameter it fails instantly with the error CURLE_COULDNT_RESOLVE_HOST(6).
So I know it's not a DNS problem since I can resolve it if I provide the URL directly.
Here is my current function.
std::string winget(std::string url)
{
CURL *curl;
CURLcode res;
std::string readBuffer;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return readBuffer;
}
//and I call it like this :
winget("example.org");
Basically if I directly replace the url param in the function with "example.org" it works. So I don't really know what to do with it.
Thanks a lot in advance. :)