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
SkyBlue2007SkyBlue2007 

Apex Http Errors !

Hi all,

 

I'm searching for Apex Http Errors.

I find out a error,  "CalloutException", for now.

 

Here is Test Class.

HttpRequest req = new HttpRequest();
   req.setTimeout(10000);
   req.setMethod('POST');
   req.setBody('&userid=testuser'+'&password=test1234');
   req.setEndpoint('http://www.sample.com');

   Http http = new Http();
   
   try {
      HTTPResponse res = http.send(req);
   }
   catch(CalloutException e) {
   }
   catch (Exception e) {
   }

 Please let me know if you have any Apex Http Errors.

And please let me know how to produce their conditions.

 

Thanks,

SkyBlue2007

Cory CowgillCory Cowgill

What is the message within the CalloutException? When you catch the exception I would add a system.debug or a message to the page showing the exact error.

 

Also, have you added your endpoint in setup remote access?

 

Setup -> Security Controls -> Remote Site Settings.

SkyBlue2007SkyBlue2007

Hi Cory,

 

Thank you for your prompt reply.

I'm sorry, my explanation was not enough.

 

I'd like to know some errors except "CalloutException".

I guess they'll happen when I try to send HttpRequest.

So, if I don't know them and how to produce their conditions,

I can't test my Apex code. And I can't raise Code Coverage.

 

Thanks,

SkyBlue2007