Created
September 30, 2016 03:11
-
-
Save TonyRenHK/1a05ff9711412b30c929b4f9c59e9923 to your computer and use it in GitHub Desktop.
HttpRequest Class Office 365
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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