Skip to content

Instantly share code, notes, and snippets.

@codefriar
Last active March 4, 2017 18:35
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 codefriar/1aefc3c291e3651207484cc5743bbb56 to your computer and use it in GitHub Desktop.
Save codefriar/1aefc3c291e3651207484cc5743bbb56 to your computer and use it in GitHub Desktop.
HttpRequest req = new HttpRequest();
req.setEndpoint('https://www.codefriar.com/bestBlogPostEver');
req.setMethod('GET');
String username = 'DoYouEvenSecurity?';
String password = 'DontHardcodeCredentials';
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment