Skip to main content

Notifications

Power Automate - Connector Development
Unanswered

Is creating this custom connector possible? Mimecast

(0) ShareShare
ReportReport
Posted on by 237

Hi, I am very new to APIs and custom connectors so please bear with me here. Mimecast is an email proxy service we use to filter and manage all email coming into our domain. Recently, we've been getting bombarded with phishing alerts from users and each time we have to manually type in the reported sender's address into our blocked senders group. This is becoming tedious and I'd like to leverage Mimecast's API to automate it more. I've set it up properly in postman and can make requests from there, but I wanted to create a custom API connector, so that I can use a trigger like 'When a new email arrives with subject: phish' then it would leverage the mimecast custom API to use their 'add-member to group' request to add the email to the blocked senders group. Sounds simple, but setting up this API is becoming increasing difficult as I am getting the below error. I assume this is because of missing authorization headers, but when looking at their documentation, it seems pretty complex and idk if I can set these headers up as default values. Please see this link for what I need as authorization headers, it involves the date, and encoding this long string in base 64. I'm thinking of giving up on the custom connector and just using an http request action, but I thought I'd share it here if someone has any ideas on properly setting this up. 

 

Authorization | Mimecast

 

I would need this request, has documentation on endpoint requests authorization header requirement's: Find Groups | Mimecast

 

 

 

Update: So I was able to make a http request via the http request action in a flow, but unfortunately this does not solve my issue because I entered static values for the authorization from recent postman runs and these values will expire after a certain amount of time (i.e you get logged out/unauthenticated). The only way I could automate this is if I had a way to get the pre request authorization script to run natively out of the custom connector or have it run some other way prior to the request.  

Here is the request in javascript

 

var uri = pm.request.url.getPath();
var baseUrl = pm.environment.get("BaseURL")
if (uri.includes(baseUrl)){
 uri = uri.replace(baseUrl, "");
}
else {
 pm.request.url = (baseUrl + uri)
}

pm.request.headers.add({ key: "x-mc-app-id", value: pm.environment.get("ApplicationID") });

var uuid = require("uuid");
var requestId = uuid.v4();
pm.request.headers.add({ key: "x-mc-req-id", value: requestId })

var date = new Date().toUTCString();
pm.request.headers.add({ key: "x-mc-date", value: date });

function Authorization() {
 var CryptoJS = require("crypto-js");
 var concat = [date, requestId, uri, pm.environment.get("ApplicationKey")].join(":");
 var encode = CryptoJS.enc.Base64.parse( pm.environment.get("SecretKey") );
 var hmac = CryptoJS.enc.Base64.stringify( CryptoJS.HmacSHA1(concat, encode) );
 var auth = "MC " + pm.environment.get("AccessKey") + ":" + hmac;
 return auth;
}
pm.request.headers.add({ key: "Authorization", value: Authorization()});

//Uncommenting this line can be useful for troubleshooting header values in the Postman console
//console.log(pm.request.headers)

 

 

Categories:
  • J0el Profile Picture
    J0el 58 on at
    Re: Is creating this custom connector possible? Mimecast

    Hey, I have an almost identical problem. I have the Pre-request Script working for my Bearer token. However, I'm not sure how to run this within Power Automate. Did you manage to solve this?

     

    TIA

     

    Joel

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,475

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,767

Leaderboard

Featured topics