+ Start a Discussion
Shiva RajendranShiva Rajendran 

How to access outlook 365 rest api using salesforce using oauth2

Hi Everyone,
I have followed the procedure to access the rest api by registering app in  https://apps.dev.microsoft.com . But when i'm making a callout for oauth authorize using the following url 
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=code&client_id=32613fc5-e7ac-4894-ac94-fbc39c9f3e4a&redirect_uri=https:%2f%2foauthplay.azurewebsites.net%2f&scope=openid+offline_access+profile+https:%2f%2foutlook.office.com%2fmail.readwrite+https:%2f%2foutlook.office.com%2fmail.readwrite.shared+https:%2f%2foutlook.office.com%2fmail.send+https:%2f%2foutlook.office.com%2fmail.send.shared+https:%2f%2foutlook.office.com%2fcalendars.readwrite+https:%2f%2foutlook.office.com%2fcalendars.readwrite.shared+https:%2f%2foutlook.office.com%2fcontacts.readwrite+https:%2f%2foutlook.office.com%2ftasks.readwrite

I'm getting status code as 200 instead of 302.Also at further notice , response.getBody() is returning html rather json , also the same get method code work's if i used in browser.
Http http1 = new Http();
        HttpRequest request1 = new HttpRequest();
request1.setEndpoint('https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=code&client_id=32613fc5-e7ac-4894-ac94-fbc39c9f3e4a&redirect_uri=https:%2f%2foauthplay.azurewebsites.net%2f&scope=openid+offline_access+profile+https:%2f%2foutlook.office.com%2fmail.readwrite+https:%2f%2foutlook.office.com%2fmail.readwrite.shared+https:%2f%2foutlook.office.com%2fmail.send+https:%2f%2foutlook.office.com%2fmail.send.shared+https:%2f%2foutlook.office.com%2fcalendars.readwrite+https:%2f%2foutlook.office.com%2fcalendars.readwrite.shared+https:%2f%2foutlook.office.com%2fcontacts.readwrite+https:%2f%2foutlook.office.com%2ftasks.readwrite');
  request1.setMethod('GET');
  HttpResponse response = http1.send(request1);

        System.debug('****'+response.getBody()   );
        System.debug('****  '+response.getStatusCode() );

Please help me with links and solutions
Thanks and Regards,
Shiva RV

 
NagendraNagendra (Salesforce Developers) 
Hi Shiva,

May I suggest you please check with below article which might help you to accelerate with above requirement. Please let us know if this helps.

Best Regards,
Nagendra.
 
Biswa RayBiswa Ray
Hi Shiva,

did you get any solution for this issue? I am exactly facing same issue while integrating Salesforce with Graph API . Please help.

thanks,
Biswa