Help writing a custom function to call an API

Help writing a custom function to call an API

Hello

I am trying to write a custom function but not having much luck in getting it to work.

Here is the API call I am making......

https://api.postcodes.io/postcodes/GL11JB

Here is the code I have written in Zoho CRM.....

resp = getUrl("https://api.postcodes.io/postcodes/GL11JB").get("result");
for each  rec in resp
{
mp = Map();
mp.put("latitude",rec.get("latitude"));
update = zoho.crm.update("Resale",contid,mp);
}

The response from the API call looks like this.....
{"status":200,"result":{"postcode":"GL1 1JB","quality":1,"eastings":383224,"northings":218261,"country":"England","nhs_ha":"South West","longitude":-2.245018,"latitude":51.862683,"european_electoral_region":"South West","primary_care_trust":"Gloucestershire","region":"South West","lsoa":"Gloucester 004B","msoa":"Gloucester 004","incode":"1JB","outcode":"GL1","parliamentary_constituency":"Gloucester","admin_district":"Gloucester","parish":"Gloucester, unparished area","admin_county":"Gloucestershire","admin_ward":"Westgate","ccg":"NHS Gloucestershire","nuts":"Gloucestershire","codes":{"admin_district":"E07000081","admin_county":"E10000013","admin_ward":"E05010967","parish":"E43000067","parliamentary_constituency":"E14000712","ccg":"E38000062","nuts":"UKK13"}}}

But in Zoho CRM I get an API failure error....

'Text' can not  be cast to 'Number'.at lineNumber -1


HELP !!