I am using Continuation for a callout in a VF page. I am getting a blank response body with StatusCode=400 . When i call the same service using normal HttpRequest, i am getting the proper response. Did any one came across a similar situation? Please help me resolve this error.

public object startServiceRequest(){
Continuation con = new Continuation(60);
    con.continuationMethod = 'processResponse';
    HttpRequest request = new HttpRequest();
    this.requestLabel = con.addHttpRequest(request);
    }catch(Exception e){
        isError = true;
        errorString = e.getMessage();
return con;}
public object processResponse(){
HttpResponse response = Continuation.getResponse(this.requestLabel);
result = response.getBody();
return null;}

I think as of now certificate based authentication is not supported in Continuation. Ref : https://www.youtube.com/watch?v=vgQe0iokHUM&feature=youtu.be&t=1926

| improve this answer | |
  • Thank you Kiran and Daniel. I have raised a case with Salesforce to get it confirmed because i didn't find any document supporting this statement. I will update here once i hear from Salesforce. – NHK Dec 9 '15 at 12:21
  • Below is the confirmation from Salesforce. The limitation with Apex Continuations is regarding Named Credentials. Presently, Named Credentials work only with regular Apex callouts. To use a client certificate in an Apex continuation, a regular Remote Site Setting URL needs to be used, and the client certificate can be set in the HttpRequest's properties either by developer name or by a base64 string of a PKCS#12 file plus that PKCS#12 file's password. – NHK Dec 10 '15 at 6:11
  • Named Credentials are somewhat new, though they have been around for several releases. Named Credentials offer a convenient way to specify the client certificate and any HTTP-level authentication within a Named Credential configuration, and Apex code can make use of that configuration by referencing the named credential in the callout URL. That feature, however, doesn't yet work with Apex Continuation callouts. – NHK Dec 10 '15 at 6:12

The issue was with the improper request body and hence I was getting error. When the request body is formatted properly, I am able to get the proper response.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.