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
basha skbasha sk 

How to maintain Session through apex REST API ?





   Hi Everyone,

      
              
               Apex class :
                ------------
                
                here at endpoint for everytime i'm generating the session value and passing statically.
                
                req.setEndpoint(url+'/api/xml?action=report-my-events&account-id=1309160790&&session=apac1breez6wnxuiam7asee4hw');                      

                session=apac1breez6wnxuiam7asee4hw this value i'm passing statically for everytime.Instead of that how to maintain the session
                through apex class.    
                
                
                global class AdobeConnectEvents{   
                
                @future (callout=true)
                global static void getParticipants(String username, String password,String url){  
                           
                    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.setEndpoint(url+'/api/xml?action=report-my-events&account-id=1309160790&&session=apac1breez6wnxuiam7asee4hw');                      
                    req.setMethod('GET');
                    req.setHeader('Content-Type', 'application/json');
                    req.setHeader('Accept','application/json');
                    try {
                        res = http.send(req);
                        System.debug('MyResult == :'+res.getBody());            
                                    
                    }catch(System.CalloutException e){
                           System.debug('Callout error: '+ e);              
                }//return res;
              }                  
            }


Thanks In Advance,
Basha