I understand I am getting this error on the map line but I do not understand why. As the method does return the list I am constructing. What am I missing about this exactly?
The dataRequest starts as a String Type JSON object.
Incoming JSON sample:
JSON =[{"crm_id":"0014000001aWzBlAAK","email_addresses":"email1, email2"}]
Code:
public static List<Contact> addConData() {
//requests the selected look
dataRequest = lookerCallout.getData('2');
dataRequest = dataRequest.replace('crm_id', 'AccountId');
dataRequest = dataRequest.replace('email_addresses', 'Email');
//This line returns the error: System.TypeException: Invalid conversion from runtime type List<ANY> to Map<String,ANY>
Map<String, Object> jsonMap = (Map<String, Object>)JSON.deserializeUntyped(dataRequest);
List<String> emailParse = ((String)jsonMap.get('Email')).split(',');
List<Contact> dataRequestList = new List<Contact>();
String accId = (String)jsonMap.get('AccountId');
for(String em : emailParse){
dataRequestList.add(new Contact(AccountId =accId, Email = em.trim()));
}
//debug piece for this method
//System.debug(dataRequestList);
System.debug(dataRequestList.size());
return dataRequestList;
}