function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rakesh Sharma 78Rakesh Sharma 78 

How to call external rest api in insecure way from salesforce apex code similar to -k in curl

Hi,
I am trying to call rest api from apex code but due to server restrictions we cannot do anything about certificate changes on target server. So, i want to call that API similar to -k or --insecure option in curl. I am getting result when i call directly with -k option using curl.

curl -k https://<URL>. --working
----------------
   request.setEndpoint('https//<URL>'); --not working.
    request.setMethod('GET');
-----------

Thanks for help in advance.
Raj VakatiRaj Vakati
You can set the http  header to the rest api call by using setHeader method  


But CURL command will not work in apex becasue apex dnt understaand what is it 
Rakesh Sharma 78Rakesh Sharma 78
Thanks Raj for your reply. Can you point me to some apex code example where setHeader is done for insecure call? 
Raju Krishnamoorthy 17Raju Krishnamoorthy 17
Hi Rakesh: Did you figure out how to set the Header or how to call the end point with -k flag set? I am running into a similar issue.  curl -k works, but I do not know how to set that via APEX method.  pl let me know