Last active
July 24, 2019 22:03
-
-
Save willyanmarques/a91d4194c8960a88bc1500e4ba7218c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class REST { | |
public static void calloutAPI(){ | |
try{ | |
Http http = new Http(); | |
HttpRequest req = new HttpRequest(); | |
req.setEndpoint('https://reqres.in/api/users?page=1'); | |
req.setMethod('GET'); | |
HttpResponse res = http.send(req); | |
if(res.getStatusCode() == 200){ | |
//Aqui vamos trabalhar do JSON | |
} else { | |
System.debug('Falha ao obter dados da API. Status code: ' + res.getStatusCode()); | |
} | |
} | |
catch(Exception e){ | |
System.debug('Exception! Mensagem: ' + e.getMessage() + ' Linha: ' + e.getLineNumber()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment