Advertisement
Guest User

Untitled

a guest
Apr 20th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. Http http = new Http();
  2. HttpRequest request = new HttpRequest();
  3. request.setEndpoint('URL');
  4. request.setMethod('POST');
  5. request.setHeader('Authorization','Basic ' +'czZCaGRSa3F0MzpnWDFmQmF0M2JW');
  6. request.setHeader('Content-Type','application/x-www-form-urlencoded');
  7. request.setBody('grant_type=password&username=USERNAME&password=PASSWORD');
  8.  
  9. HttpResponse response = http.send(request);
  10. // Parse the JSON response
  11. if (response.getStatusCode() != 201) {
  12. System.debug('The status code returned was not expected: ' +
  13. response.getStatusCode() + ' ' + response.getStatus());
  14. } else {
  15. System.debug(response.getBody());
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement