Met in a problem of how to get the records of temperature from the public portal. i didnt get the data updated in salesforce org.
global class WeatherBatch implements Database.Batchable<sObject>,Database.AllowsCallouts,Database.Stateful{
public static void futureMethod(){
HttpRequest request = new HttpRequest();
Http http = new Http();
request.setEndpoint('https://api.weatherbit.io/v2.0/current?city=Mumbai&key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
request.setMethod('GET');
HttpResponse response= http.send(request);
if(response.getStatusCode() == 200){
Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
List<Object> data = (List<Object>) results.get('data');
System.debug(data.size());
System.debug('Received the following data:');
for (integer i=0; i<data.size(); i++)
System.debug(data);
}
}
Aucun commentaire:
Enregistrer un commentaire