+ Start a Discussion
suyogya jain 6suyogya jain 6 

URGENT!!!!! Invalid conversion from runtime type List<ANY> to Map<String,ANY>

  Map<String,Object> results = (Map<String,Object>)JSON.deserializeUntyped(response.getBody());
                list<object> attchlist;
                list<ContentVersion> CV = new list<ContentVersion>();
                list<ContentDocumentLink> CDLink = new list<ContentDocumentLink>();
                Set<Id> contentDocumentIds = new Set<Id>();
                Set<FileData> fileFromSAP = new Set<FileData>();
                for(Object mapa:results.values() ){
                    Map<String,Object> tempMap = (Map<String,Object>)mapa;
                    map<string,object> attc = (Map<String,Object>)tempMap.get('Attachment');

This exception is coming while running the code...someone please help
mukesh guptamukesh gupta
Hi Suyogya,

As per in your code you are converting in MAP, this may be a issue, here you need to check in JSON
map<string,object> attc = (Map<String,Object>)tempMap.get('Attachment');

you can follow below example:-
String payload = '{"data": [{"s": "a", "i": 1}]}';
Map<String, Object> deserialized = (Map<String, Object>)JSON.deserializeUntyped(payload);
List<Map<String, Object>> data = new List<Map<String, Object>>();
for (Object instance : (List<Object>)deserialized.get('data'))
    data.add((Map<String, Object>)instance);

If this solution is usefull for you, Please mark as a Best Answer to help others.