SHARE
TWEET

Untitled

a guest Dec 10th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @InvocableMethod(Label ='Do Callout' description='does a callout')
  2. public static List<String> DoCallout(List<String> input){
  3.     String city = input.get(0);
  4.     Http http = new Http();
  5.     HttpRequest request = new HttpRequest();
  6.     request.setEndpoint('https://api.openweathermap.org/data/2.5/weather?q='+city+'&APPID=67fc7cb50b5b109eb50966923d8e4fcc');
  7.     request.setMethod('GET');
  8.     HttpResponse response = http.send(request);
  9.     if (response.getStatusCode() == 200) {
  10.        Map<String, Object> results = (Map<String, Object>)
  11.        JSON.deserializeUntyped(response.getBody());
  12.  
  13.        List<Object> animals = (List<Object>) results.get();
  14.        return animals;
  15.     }
  16.     return new List<String> {'Test'};
  17. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top