Mimecast error The remote server returned an error: (418)


Summary

This articles explains steps to take if you get error The remote server returned an error: (418) when you click on Create Account for Mimecast.

Applies To

This article applies to MachPanel 6.0.20 HF1 and above.

Summary

If you are getting below error in MachPanel for Mimecast account creation:
The remote server returned an error: (418)


You need to re-generate and update Access and Secret key in API settings.

Copy below in PowerShell (run on any machine with internet access as admin). You will be asked for Mimecast API Login & Password and if you provide correct details, you will get new Access key and Secret Key:

Once you get fresh Access Key and Secret key, update in MachPanel under [Home > Service Director > Mimecast > MimeCast API Settings].

Note

To avoid access key and secret key expiration, Please set "Authentication Cache TTL" setting in the service user's effective Authentication Profile to "Never Expire".


PowerShell Script

$creds = Get-Credential
$discoverPostBody = @{"data" = ,@{"emailAddress" = $creds.UserName}}
$discoverPostBodyJson = ConvertTo-Json $discoverPostBody
$discoverRequestId = [guid]::NewGuid().guid
$discoverRequestHeaders = @{"x-mc-app-id" = "4941cc2e-85e5-4988-af50-688b03a29f96"; "x-mc-req-id" = $discoverRequestId; "Content-Type" = "application/json"}
$discoveryData = Invoke-RestMethod -Method Post -Headers $discoverRequestHeaders -Body $discoverPostBodyJson -Uri "https://sandbox-api.mimecast.com/api/login/discover-authentication"
$baseUrl = "https://sandbox-api.mimecast.com"
$keys = @{}
$uri = $baseUrl + "/api/login/login"
$requestId = [guid]::NewGuid().guid
$netCred = $creds.GetNetworkCredential()
$PlainPassword = $netCred.Password
$credsBytes = [System.Text.Encoding]::ASCII.GetBytes($creds.UserName + ":" + $PlainPassword)
$creds64 = [System.Convert]::ToBase64String($credsBytes)
$headers = @{"Authorization" = "Basic-Cloud " + $creds64; "x-mc-app-id" = "4941cc2e-85e5-4988-af50-688b03a29f96"; "x-mc-req-id" = $requestId; "Content-Type" = "application/json"}
$postBody = @{"data" = ,@{"username" = $creds.UserName}}
$postBodyJson = ConvertTo-Json $postBody
$data = Invoke-RestMethod -Method Post -Headers $headers -Body $postBodyJson -Uri $uri
"Access key: " + $data.data.accessKey
"Secret key: " + $data.data.secretKey