Guest User

Untitled

a guest
Dec 10th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment