+ Start a Discussion
Aryan JhaAryan Jha 

Illegal conversion from Object to Map<String,Object> at line 17 column 1

public class ForiegnExchangeCallout
{
public static Map<String,Object> getrates(String url)
{
Http http=new Http();
HttpRequest req=new HttpRequest();
req.setEndPoint(url);
req.setMethod('GET');
HttpResponse res=http.send(req);
system.debug(+res.getbody());
Map<String,object> result=  (Map<String,object>)JSON.deserializeUntyped(res.getBody());
Map<String,Object>rates=(Map<String,Object>)result.get('inr');
for(Object INR:rates)
{
system.debug('rates of inr is'+INR);
return INR;
}

}
}
CharuDuttCharuDutt
Hii Aryan Jha
Try Below Code
public class ForiegnExchangeCallout
{
public static Map<String,Object> getrates(String url)
{
Http http=new Http();
HttpRequest req=new HttpRequest();
req.setEndPoint(url);
req.setMethod('GET');
HttpResponse res=http.send(req);
system.debug(+res.getbody());
Map<String,object> result=  (Map<String,object>)JSON.deserializeUntyped(res.getBody());
Map<String,Object>rates=(Map<String,Object>)result.get('inr');
for(Object INR:rates.values())
{
system.debug('rates of inr is'+INR);
//return INR;
}
    return rates;

}
}
Please Mark It As Best Answer If It Helps
Thank You!