Call Rest Api and Json Parsing in Salesforce
Requirement : To Call Current weather api show data on VF page, Based on Search City Solution: Call the rest api and parse the json and one more thing add End Point url in Remote Site Setting First Step : Create a Class and Parse the JSON data Create Class: CurrentDayWeatherApiController Class Code: public class CurrentDayWeatherApiController { public string cityName{get;set;} // public boolean showpanel{get;set;} public List<weatherRecords> WeathersList{get; set;} public CurrentDayWeatherApiController() { } public void ShowWeather() { try { if(cityName!=null && cityName!='') { string endPointURL = 'http://api.openweathermap.org/data/2.5/find?q='+cityName; Httprequest req = new Httprequest(); req.setEndpoint(endPointURL); req.setMet