Making https calls from user defined UDF

Hi, Has any one tried making any external api calls over https. from UDF functions defined in C++. We tried but it gets into some library issue. Will share the logs in short while. But any external call to http works. Has any one tried this and it worked ?

@kapilsaini It’s been discussed a couple times in the community, but I think you’re the first to try the implementation. Can you share relevant information? Logs. UDF snippet. What issues pop up?

At the first glance, it looks more like C++ issue, not TigerGraph issue.

HTTPS requests involve certificates and other stuff to be configured…

For example, take a look at this one: https://www.reddit.com/r/cpp_questions/comments/q7ho2b/trying_to_make_https_requests_in_c/

Hello @Jon_Herke , I am following up on @kapilsaini’s question to share the logs. When the c++ function is run by itself it works with curl. There is no issues with the UDF function. However, when we call the UDF function in tg server, curl doesn’t work as part of the c++ library in tg server because we get the CURLE_OK as 1 which is refers to the curse_unsupported_protocol(1). The link I use for test is “https://www.google.com” and CURLE_OK was 1. Is there any specific configuration we need to enable to resolve this?

Below is the UDF snippet:

inline string test_curl(string url_s)
{ string retStatus;
try{
retStatus=“NotExecuted”;

    CURL *curl;
    CURLcode res;
    string readBuffer;

    curl = curl_easy_init();
    std::cout<<"+++++++++++Hello let's test++++++++"<<std::endl;
    if (curl)
    {
      curl_easy_setopt(curl, CURLOPT_URL,url_s.c_str());
      curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
      curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
      curl_easy_setopt(curl, CURLOPT_TIMEOUT, 20L);

      res = curl_easy_perform(curl);
      std::cout<<res<<" ++++++++++++++++++++++++Error code"<<std::endl;
      if(res != CURLE_OK)
      {
        retStatus="FAILED";
        std::cout<< " Curl Failed " << curl_easy_strerror(res) << " URL Used "<< url_s << std::endl;
      }
      else{
              std::cout<<readBuffer<<std::endl;
      }
      curl_easy_cleanup(curl);
    }

}
catch(…){
std::cout<<"+++++++++++++++Check the error status from curl"<<std::endl;
}
return retStatus;
}

Hi @Jon_Herke any further inputs on making https calls using curl library packaged with TG. as of 3.5.3 version it doesn’t support https. Can you confirm if any later versions can use those. If no, is there a provision to update/add third party libraries (that supports https) on TG cloud ?

@kapilsaini There hasn’t been any added support for native HTTP / HTTPS (functions) on any of the latest releases. As for question #2 not that I’m aware of. Some folks have built the request capabilities outside of TG such as this pattern.

Using pyTG:
(GSQL) Query 1 - pull data out
REST - using python request makes a call with extracted data
(GSQL) Query 2 - Upserts values back into the graph