Automic Workload Automation

 View Only
  • 1.  Microsoft Graph API

    Posted Jun 25, 2019 07:42 AM

    Hi,
    does anyone have experience with the Microsoft Graph API?
    I would like to retrieve an Outlook 365 mailbox automatically with Curl and Automic.

    Best regards

    Stefan



  • 2.  RE: Microsoft Graph API

    Posted Jun 27, 2019 10:07 AM
    I'm planning to dive into that topic somewhen in the next few weeks. All I know so far is that you need an API key. So far I'm not sure whether I'll go for PowerShell or the Webservice object to implement the logic. If you're getting any result I'll be glad to hear about ;-).


  • 3.  RE: Microsoft Graph API
    Best Answer

    Posted Jun 28, 2019 02:06 AM
    Hi,
    not really nice yet, but it's working now. :) I use Invoke-RestMethod with Powershell.
    You have to create an APP in the Azure Cloud. With the Client ID and the Secret of the App and the Directory ID you can create an Access Token (expires after 3600s).
    The configuration of the proxy and the permissions of the app were the biggest problems.
    I can give you more details next week. At the moment I don't have much time because the jobs have to be finished ;)
    Best regards
    Stefan

    ------------------------------
    Mast-Jägermeister SE
    ------------------------------



  • 4.  RE: Microsoft Graph API

    Posted Jul 10, 2019 09:10 AM
    So you built an app in the azure cloud which handles the events raised by O365 if, for example, a new mail arrives? Then the app is forwarding the data to the Automic REST API?

    ------------------------------
    Swisscom & WorkflowCommander
    ------------------------------



  • 5.  RE: Microsoft Graph API

    Posted Jul 29, 2019 03:30 AM
    You need the app to create a Client Secret and you can set the permissions there e.g. Mail.Read.
    http://codematters.tech/getting-access-token-for-microsoft-graph-using-oauth-rest-api/

    The job calls the Microsoft Graph API (not Automic REST API) via invoke-RestMethod e.g. https://graph.microsoft.com/v1.0/me/messages

    My Powershell script to check the inbox for unread mails. Only the columns id,subject,from,hasAttachments are displayed. And $count=true counts the mails.
    $url = "https://graph.microsoft.com/v1.0/users/&userid#/mailFolders/inbox/messages"
    $token = '&token#'
    $params = @{
        Uri         = 'https://graph.microsoft.com/v1.0/users/&userid#/mailFolders/inbox/messages?$filter=isRead+eq+false&select=id,subject,from,hasAttachments&$count=true'
        Headers     = @{ 'Authorization' = "Bearer $token" }
        Method      = 'GET'
        ContentType = 'application/json'
        Proxy       = 'http://proxy:ip'
    }
    
    $messages = Invoke-RestMethod @params​
    I process the result in the Post-Script.

    ------------------------------
    Mast-Jägermeister SE
    ------------------------------



  • 6.  RE: Microsoft Graph API

    Posted Jul 29, 2019 06:04 AM
    Ah cool, that would be the polling way. I would be interested in having O365 push messages to Automic. Either to IA or (more preferred) to the AE REST interface. Like a mail arrives and starts an Automic job, passing the raw mail content to the job. Not as simple as polling but that would be fantastic!

    ------------------------------
    Swisscom & WorkflowCommander
    ------------------------------