web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Is creating this custo...
Power Automate
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:
I have the same question (0)
  • J0el Profile Picture
    58 on at

    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard