I have two methods 1) getSiteIds and 2) fetchSession. In the first method getSideIds I want to populate an empty `Map<String,String> siteIds = new Map<String,String();` with (name, id): Map<String,String> siteIds = new Map<String,String(); for (Object dataIte : data) { Map<String, Object> dataMapIte = (Map<String, Object>) dataIte; String id = (String) dataMapIte.get('id'); Map<String, Object> attributes = (Map<String, Object>) dataMapIte.get('attributes'); String name = (String) attributes.get('name'); siteMap.put(name, id); finalList.add(name); } **NOTE**: I declared the siteIds map outside of the method with public accessibility, so it should be available to other methods? In the second method fetchSession I want to search for id of a site and I provide the name: Data data = new Data(); data.website_id = siteMap.get(selectedSiteName); I wrote `system.debug(data.website_id);` just so I test this but I get null value: [Link][1]. Any suggestions on how can I set the values of the siteIds with the first method and then use the map in the second method? **getSiteIds method:** @AuraEnabled(cacheable=true) public static List<String> getSiteIds(String webSiteId, String token) { try{ // CUSTOMIZE THE ENDPOINT FOR THE GIVEN METHOD String customEndpoint = webSiteId + '/api/apps/v2'; //String token = AccessTokenGetSet.getSetToken; // MAKE THE API CALL HttpRequest req = new HttpRequest(); req.setMethod('GET'); req.setHeader('Content-Type','application/vnd.api+json'); req.setHeader('Authorization','Bearer ' + token); req.setEndpoint(customEndpoint); Http h = new Http(); HTTPResponse res = h.send(req); if (res.getStatusCode() == 200){ Map<String,Object> results = (Map<String, Object>)JSON.deserializeUntyped(res.getBody()); List<Object> resultsData = (List<Object>)results.get('data'); List<String> finalList = new List<String>(); List<Object> data = (List<Object>) results.get('data'); for (Object dataIte : data) { Map<String, Object> dataMapIte = (Map<String, Object>) dataIte; String id = (String) dataMapIte.get('id'); Map<String, Object> attributes = (Map<String, Object>) dataMapIte.get('attributes'); String name = (String) attributes.get('name'); siteMap.put(name, id); finalList.add(name); } return finalList; } else { System.debug('ELSE'); return null; } } catch (exception ex){ System.debug(ex.getMessage()); return null; } } **fetchSession method:** @AuraEnabled(cacheable=true) public static List<Object> fetchSessions (String webSite, String selectedSiteName, List<String> stringColumns, String date_from, String date_to, String token){ try{ // GET API NAMES OF THE SELECTED DIMEONSIONS Schema.DescribeFieldResult objFieldDescribe = Piwik__c.Choose_dimensions__c.getDescribe(); List<Schema.PicklistEntry> lstPickListValues = objFieldDescribe.getPickListValues(); String elementValue; String elementLabel; List<String> apiNamesList = new List<String>(); for (Schema.PicklistEntry objPickList : lstPickListValues) { elementLabel = objPickList.getLabel(); if (stringColumns.contains(elementLabel)){ elementValue = objPickList.getValue(); apiNamesList.add(elementValue); } } // CUSTOM ENDPOINT String customEndpoint = webSite + '/api/analytics/v1/sessions/'; // CUSTOM BODY **Data data = new Data(); data.website_id = siteMap.get(selectedSiteName);** System.debug(data.website_id); // BODY column List<Data.Column> columnWrapper = new List<Data.Column>(); Data.Column c = new Data.Column(); for (String column_id : apiNamesList) { c.column_id = column_id; columnWrapper.add(c); } data.columns = columnWrapper; data.date_from = date_From; data.date_to = date_to; data.offset = 0; // hardcoded for now, if wished - can be dynamically sent to the request - TESTED data.format = 'json'; // hardcoded for now, if wished - can be dynamically sent to the request - TESTED // MAKE THE API CALL HttpRequest req = new HttpRequest(); req.setMethod('POST'); req.setHeader('Content-Type','json'); req.setHeader('Authorization','Bearer ' + token); req.setHeader('Accept-Encoding', 'gzip'); // piwik's advice - enable encoding/compression when pulling large amounts of data https://prnt.sc/LzsAv6K4_NTk req.setEndpoint(customEndpoint); req.setBody(JSON.serialize(data)); Http h = new Http(); HTTPResponse res = h.send(req); if (res.getStatusCode() == 200){ Map<String,Object> results = (Map<String, Object>)JSON.deserializeUntyped(res.getBody()); List<Object> responseData = (List<Object>) results.get('data'); // Return data List<Object> return responseData; } else { System.debug(res.getBody()); System.debug(res.getStatusCode()); System.debug('ELSE'); return null; } } catch (exception ex){ System.debug(ex.getMessage()); return null; } } [1]: https://prnt.sc/dNHctA8muSQJ