So I am using libcurl with C++ to retreive the data in a page, but for some reason it throws the error in the post title when I connect to my vps. The code in the vps just makes a get request and spits out some data from my database.
#include "requestMapper.hpp"
// Send a GET request to API to retreive image
void RequestMapper::retreiveData(std::string url) {
CURL *curl;
CURLcode res;
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if(curl) {
ISSUE HERE // curl_easy_setopt(curl, CURLOPT_URL, "https://104.236.200.91/index.php/food/");
res = curl_easy_perform(curl);
#ifdef SKIP_PEER_VERIFICATION
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
#endif
#ifdef SKIP_HOSTNAME_VERIFICATION
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#endif
res = curl_easy_perform(curl);
if (res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
curl_easy_cleanup(curl);
}
curl_global_cleanup();
}
// Submit a post request to API link to send data
void RequestMapper::postData() {
}
int main(void) {
RequestMapper rm;
rm.retreiveData("sample");
return 0;
}
This code is working fine when the url is something like "https://google.com" but when I hit the link to my web server I set up I get that error. I am newer to this library, but I thought I was doing things correctly. if anyone has any insight please let me know! I'll continue to tinker with this and if I find a solution I'll share it here.
Thanks!
EDIT:
I recently solved this issue and wanted to share it with anyone who might stumble upon this post.
I was using https://URL when instead I should have been using http://URL so if you run into this issue try using that instead first!