Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Http http = new Http();
- HttpRequest request = new HttpRequest();
- request.setEndpoint('URL');
- request.setMethod('POST');
- request.setHeader('Authorization','Basic ' +'czZCaGRSa3F0MzpnWDFmQmF0M2JW');
- request.setHeader('Content-Type','application/x-www-form-urlencoded');
- request.setBody('grant_type=password&username=USERNAME&password=PASSWORD');
- HttpResponse response = http.send(request);
- // Parse the JSON response
- if (response.getStatusCode() != 201) {
- System.debug('The status code returned was not expected: ' +
- response.getStatusCode() + ' ' + response.getStatus());
- } else {
- System.debug(response.getBody());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement