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

HttpRequest with https (secure) URL fails the first time?

We have an Apex web service that calls out to a RESTful web service with the Http.send() method.


When the URL is http (i.e. non-secure http), all works great. But, if we change only the protocol to https the response is a "Bad Request" error code 400. 


The strange thing is that it works if we issue the Http.send() command a second time right after getting the failure, i.e. the Http.send() fails the first time, but succeeds if called again.


Looking at the debug log's time stamps, we can see that the failure response is coming back in 0 time, i.e. it looks like the request isn't really going out at all to the remote server.



Message Edited by jbjb on 05-18-2009 05:18 PM
Message Edited by jbjb on 05-19-2009 09:33 AM
Vijay RautVijay Raut



Have you got any reason / root cause / workaround for this problem?


In my application, We are calling external web service. It is working fine and i am getting response back.

Then we are looking for implementing compression using "setCompressed()" method. And now i am getting "BAD REQUEST - 200" response from web service. Any thoughts?


Thanks in advance.








We never found the root cause, but we did use a workaround: create a loop and retry a few times until the call succeeds. Usually only 1 retry is necessary, sometimes 2. 


Did you re-try the call a second, or third, time with any different results? Perhaps verify that the server will receive compressed requests? That's all I can think of...


Please post any solutions or workaround you get.



Any updates or new solution to this problem available?