REST API data connection for webhook

Hi there,

I’ve been trying to set up a data connection to REST API to use in a webhook (send automated email on outlook upon action completion). When testing the webhook, I am getting error access denied.

I have tried using data connection authentication “Bearer Token” and “API key”, OAuth 2.0 is unavailable. Unsure if this is causing the error.

I have set up an egress policy for graph.microsoft.com (Port 443) which I have understood as the most suitable approach for sending emails to outlook. This has been approved.

Do you have any recommendations on how to resolve the error?

Thanks!

Hey @amhall,

I think I have exactly the setup you’re looking for. I have also set up a Rest API connection / Webhook for connecting to MS Exchange / Graph API and sending emails.

The tricky part here is that you need to get an AuthToken first from login.microsoftonline.com to get a token you can use at graph.microsoft.com

The way to make this work is to specify two different domains in your connection settings, both of which have Authentication set to None. You will want to specify your credentials (probably tenantId, clientId and clientSecret) that you will use to authenticate against login.microsoftonline.com as additional secrets. See screenshot below:

Once you have configured your source like this, you can configure your webhooks to make two requests.

  1. Login using the credentials at login.* to get a short-lived access_token.
  2. Make the API call (e.g. sendMail) to graph.*. Use the “access_token” in the response from Call 1 as the bearer token in the Authentication Header.

See screenshot for a setup that works.

FYI you will need a 2nd egress policy here for the second domain.

Hope this helps!