I was trying to do a callout from a VF page constructor. I'm using Continuation class. As I've to show the response in the Page. Yhe problem is the callout method is not called.

Below is the code, I checked in the debug log the method processResponse never called.

public Object startRequest(string DocId) {
        Continuation con = new Continuation(40);
        HttpRequest req = new HttpRequest();
        req.setEndpoint('URL');//end point URL
        req.setHeader('Content-Type', 'application/json');
         String body = CalloutHandler.getStatus(DocId);
        requestLabel = con.addHttpRequest(req);
        return con;  

// Callback method

    public Object processResponse() { 
        HttpResponse response = Continuation.getResponse(this.requestLabel);
        GetDrawingStatusResponse resp = New GetDrawingStatusResponse ();
        result = response.getBody();
To Do logic 

        return null;

1 Answer 1


From the documentation of Continuation.

A user invokes an action on a Visualforce page that requests information from a Web service (step 1). The app server hands the callout request to the Continuation server before returning to the Visualforce page (steps 2–3). The Continuation server sends the request to the Web service and receives the response (steps 4–7), then hands the response back to the app server (step 8). Finally, the response is returned to the Visualforce page (step 9).

enter image description here

The important bit to look is, "A user invokes an action on a Visualforce page that requests information from a Web service"

The constructor is not an Action. And as the continuation method is not called from an ACTION it won't execute.

If you still wanna make a callout on PAGE load, similar to the constructor, you can use "action" attribute of VF Page.

<apex:page action="{!doContinuationAction}">
Your Body

Src: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_continuation_overview.htm

src: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_page.htm

  • I've tried using Page action, still the callback method is not executing
    – ds9972
    Dec 19, 2018 at 12:02
  • Are there more than 2 methods with name "processResponse" ? Dec 19, 2018 at 12:04
  • No, only one method named "processResponse"
    – ds9972
    Dec 19, 2018 at 12:09
  • can you try calling that method from command-button and see if it works? Dec 19, 2018 at 12:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .