I want to call a url using Rest API from my apex controller and show the response from that url to my visualforce page. I have written a code. But it is not working.
Controller
public class RestApi_Controller{
public HTTPResponse res{get; set;}
public String resBody{get; set;}
public String endpoint{get; set;}
@future(callout=true)
public static void submit(){
HttpRequest req = new HttpRequest();
req.setMethod('GET');
//Seting HttpRequest Method
req.setHeader('content-type', 'application/json');
//Seting HttpRequest header properties
req.setHeader('Content-Length', '2000');
req.setEndpoint('https://cosprdapi.cadence.com/cdpaccess/Ldap_FolderUpload/CreateSearchUserServlet?uid=******&pwd=*****' );
Http http = new Http();
try{
HTTPResponse res = http.send(req);
//Executing web service call
System.debug('STATUS:' + res.getStatus());
System.debug('STATUS_CODE:' + res.getStatusCode());
}
catch(System.CalloutException e){ {
//Exception handling goes here..
system.debug(e);
}
}
}
Here is my vf page:
Best Answer
You are sending some extra parameters I remove them and got
200
status.Here are the success status