Skip to content

Instantly share code, notes, and snippets.

@arun12209
Created April 12, 2020 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arun12209/bffd180b5495849c75304114c8e3320f to your computer and use it in GitHub Desktop.
Save arun12209/bffd180b5495849c75304114c8e3320f to your computer and use it in GitHub Desktop.
NEWSAPI_Callout
string baseURL='https://newsapi.org/v2/top-headlines';
String apiKey =''; //API key get it from Newsapi.org
HttpRequest reqest = new HttpRequest();
system.debug('EndPoint: '+baseURL+'?sources=national-geographic&apiKey='+apiKey);
reqest.setEndpoint(baseURL+'?sources=national-geographic&apiKey='+apiKey);
reqest.setMethod('GET');
reqest.setHeader('Accept','application/json');
Http h = new Http();
HTTPResponse response = h.send(reqest);
System.debug('result : + response.getBody());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment