locked
Calling Office365 MVC sample from Windows Service RRS feed

  • Question

  • I've created a MVC Web application to get emails and put it to my database. I managed to gather the emails based on that sample, which works perfectly:

    https://msdn.microsoft.com/office/office365/HowTo/getting-started-Office-365-APIs?f=255&MSPPError=-2147217396

    Then I put that sample to my localhost, and call that webpage from a Windows Server in every 60 seconds. Actually I've managed to do that too. 

    So here is my problem:

    When I call the page from my browser, the page works and it returns the result screen.

    But when I call the exact same page from the windows server, it returns the Login screen for Office 365. (I check the result from the eventlog.) So obviously no one logs in, and the page doesn't work.

    Here is my question:

    Is it possible to call my the page from Windows Server and not getting the Office 365 login screen before the actual MVC page?

    Actually, when I try to call the page from different browser, and it asks for login screen too, but only for the first time. Then it returns to normal.

    Maybe I should create some cookies in my Windows Service HttpWebRequest?

    Thanks;

    Wednesday, July 15, 2015 9:55 AM

Answers

  • Hi Necati,

    Yes, you could not connect to Office 365 API in your windows service.

    >> What would you suggest to push some mails from our Outlook Account to Sql database?

    Do you mean push mails from Outlook to sql database in the windows service? I am afraid that you could not achieve this with Office 365 API. Maybe you could try ews in Exchange, but I am not sure, I am not familiar with Exchange.

    # How to: Work with Exchange mailbox items by using EWS in Exchange
    https://msdn.microsoft.com/en-us/library/office/dn535506%28v=exchg.150%29.aspx?f=255&MSPPError=-2147217396

    Hope it will help.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Marked as answer by Hakan ERDOGAN Monday, July 20, 2015 8:23 AM
    Friday, July 17, 2015 8:33 AM

All replies

  • Hi Necati,

    >> When I call the page from my browser, the page works and it returns the result screen. But when I call the exact same page from the windows server, it returns the Login screen for Office 365.

    I assume that before you call the page from your browser, you have logged in the Login screen for Office 365? Am I right? As far as I know, you need to login Office 365 site, and then you could call Office 365 APIs. There is no way for you to call Office 365 API without login in Office 365.

    >> Is it possible to call my the page from Windows Server and not getting the Office 365 login screen before the actual MVC page?
    No, it is impossible. The Office 365 login screen is used for authentication, if you did not login, you would not have authority to access Office 365 APIs.

    >> Maybe I should create some cookies in my Windows Service HttpWebRequest?
    No, you could not. Office 365 do not support performance authority with account and password in the url. You need to performance authority in Office365 login site. So, it would not work with HttpWebRequest.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, July 16, 2015 6:06 AM
  • Hello Edward,

    Thank you for the information.

    Yes you assumed right: I logged in to the system once I called the page. Then it stopped asking again and run the page directly. So I thought it is the affect of the tokens created in ADALTokenCacheDb.mdf file. 

    I want to reach the information which causes the page to run directly for the second time, and use it in Windows Service to run the page directly from there. 

    So it's not possible at all, you say? What would you suggest to push some mails from our Outlook Account to Sql database?

    Thanks,

    Thursday, July 16, 2015 9:24 AM
  • Hi Necati,

    Yes, you could not connect to Office 365 API in your windows service.

    >> What would you suggest to push some mails from our Outlook Account to Sql database?

    Do you mean push mails from Outlook to sql database in the windows service? I am afraid that you could not achieve this with Office 365 API. Maybe you could try ews in Exchange, but I am not sure, I am not familiar with Exchange.

    # How to: Work with Exchange mailbox items by using EWS in Exchange
    https://msdn.microsoft.com/en-us/library/office/dn535506%28v=exchg.150%29.aspx?f=255&MSPPError=-2147217396

    Hope it will help.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Marked as answer by Hakan ERDOGAN Monday, July 20, 2015 8:23 AM
    Friday, July 17, 2015 8:33 AM
  • Good Morning Edward,

    Thank you for your help. The link you provided is exactly what I was looking for. I managed to do what I want to do.

    Thanks;

    Monday, July 20, 2015 8:23 AM