2

Actually I'm doing Adobe connect integration with Salesforce.For that I wrote the REST api that works perfectly but here the problem is for every time i'm checking the cookie value is changed , so how to maintain the cookie values in apex class.

if anybody having idea please help me

This is my REST class:

global class LeadExportToAdobe{

    @future (callout=true)
    global static void exportLead(String username, String password, String endpointUrl,String LastName,String Email){

        Http http = new Http();
        HttpRequest req =  new HttpRequest();
        HttpResponse res = new HttpResponse();                            
        Blob headerValue = Blob.valueOf(username + ':' + password);
        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        req.setHeader('Content-Type', 'application/json');
        req.setEndpoint(endpointUrl+'/api/xml?account-id=1300650024&session=apac1breezkaiod5x45829zuo9&action=event-register&sco-id=1306838132&login=Email&password=1234&password-verify=1234&first-name=LastName&last-name=LastName');
        req.setMethod('POST');
        try{

            res = http.send(req);
            System.debug('MyResult == :'+res.getBody());

        } catch(System.CalloutException e){

            System.debug('Callout error: '+ e);
        }                  
    }
}

1 Answer 1

3

Rather than storing and retrieving from cookies, leverage Platform Cache

With this, use Cache.Session methods.

Usage

Storing value in session cache:

Cache.Session.put('local.myPartition.firstname', firstName);

Retrieving values from cache:

String firstName = (String) Cache.Session.get('local.myPartition.firstname');

Note that, Cache.Session.get always returns Object type, so you need to typecast it to desired datatype.

1
  • Is it possible to access the session cache set in User's session inside the @future callout method which is called from that same User's session?
    – Mohan P
    Jan 16, 2020 at 20:12

You must log in to answer this question.