Skip to content

Instantly share code, notes, and snippets.

@TonyRenHK
Created September 30, 2016 03:11
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 TonyRenHK/1a05ff9711412b30c929b4f9c59e9923 to your computer and use it in GitHub Desktop.
Save TonyRenHK/1a05ff9711412b30c929b4f9c59e9923 to your computer and use it in GitHub Desktop.
HttpRequest Class Office 365
HttpRequest req = new HttpRequest();
Http http = new Http();
//req.setheader('accept','application/json');
//https://tonyren-my.sharepoint.com/_api/v1.0/me/files/016EQYPSSQZ3I757WQYVALBAADZKWLQDTI/children?expand=thumbnails
req.setEndpoint('callout:Office365NamedCredential2/drive/root'); //me/drive/root/children'
req.setheader('accept','application/json');
req.setHeader('Authorization', 'Bearer {!$Credential.OAuthToken}');
//req.setHeader('Content-Type', 'application/json');
req.setMethod('GET');
try {
HttpResponse response = http.send(req);
if ( response.getStatusCode() != 200 ) {
System.debug('Error response: ' + response.getBody());
} else {
System.debug('Successful response: ' + response.getBody());
}
}
catch( exception ex){
system.debug('Exception caught: ' + ex.getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment