0

I have a working version of using an apex continuation in a VF page for parallel and chained callouts. Now I need to use a continuation from a Lightning Component so I implemented the Continuation Proxy component from the Salesforce Developers Blog. I can attach multiple HTTP requests to the continuation and I have confirmed all requests reach my server and complete successfully. I have confirmed the continuation calls my callback method.

In the callback method, Continuation.getResponse(requestlabel) always returns null. requestlabel has a valid value too, "Continuation-1".

I have tested the ContinuationProxy in a lightning component app and on a record detail page.

This is failing in a sandbox org with a domain set.

This code does work correctly in a developer org, meaning, it seems to be failing in this sandbox org only.

Has anyone seen this before or can help me in the right direction?

@RemoteAction
global static Object invoke(String methodName, String[] params) {

    // Create a Continuation for the HTTPRequest        
    Continuation con = new Continuation(60);
    con.continuationMethod = 'callback'; 

    ...
    //Add http request to continuation

    return con;
}

global static Object callback(list<string> labels, Object state) {
    system.debug(labels);       
    for (string l : labels) {
        system.debug(l);
        HttpResponse response = Continuation.getResponse(l);
        system.debug(response);            
    }

    ...
}

13:53:04.0 (1053483)|USER_DEBUG|[160]|DEBUG|(Continuation-1)
13:53:04.0 (1143478)|USER_DEBUG|[162]|DEBUG|Continuation-1
13:53:04.0 (1235817)|USER_DEBUG|[164]|DEBUG|null

2
  • What does label contain? Can you try getting the response as HttpResponse response = Continuation.getResponse((String)state); and have method parameter as state only? like global static Object callback(Object state) Commented Feb 20, 2018 at 6:00
  • The logs are shown at the bottom of the post for the three debug statements. My original attempt used the global static Object callback(Object state) signature. Commented Feb 20, 2018 at 6:02

1 Answer 1

0

Only with a managed package could I reproduce the issue.

I needed to pass a continuation to a class in a managed package. The class then created a web request and added it to the continuation object.

I first tried for unpackaged code to create the HTTP request and have packaged code add it to the continuation but that did not work.

The solution is for unpackaged code to create and add the request to the continuation. The packaged code should just set the request properties.

You must log in to answer this question.

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