def send_post_request(self, payload, request_uri):
        """Sending POST requests to Mimecast API."""
        headers = self.generate_proper_headers(request_uri)
        proxies = {}
        if hasattr(self, 'https_ip') and self.https_ip:
            https_proxy = 'https://{https_ip}:{https_port}'.format(https_ip=self.https_ip, https_port=self.https_port)
            proxies.update({'https': https_proxy})
        if hasattr(self, 'proxy_username') and self.proxy_username:
            auth = 'https://{proxy_username}:{proxy_password}@{https_ip}:{https_port}/'.format(
                proxy_username=self.proxy_username,
                proxy_password=self.proxy_password,
                https_ip=self.https_ip,
                https_port=self.https_port)
            proxies.update({'https': auth})
        try:
            if proxies:
                response = requests.post(url=self.base_url + request_uri,
                                         headers=headers,
                                         data=str(payload),
                                         timeout=120,
                                         proxies=proxies)
            else:
                response = requests.post(url=self.base_url + request_uri,
                                         headers=headers,
                                         data=str(payload),
                                         timeout=120)
        except Exception:
            raise MimecastRequestError("Call to " + self.base_url + request_uri + " failed.")

        if response.status_code == MimecastResponseCodes.quota_exceeded:
            sleep_duration = math.ceil(int(response.headers['X-RateLimit-Reset']) / 1000)
            logging.info('Rate limit hit. Sleeping for {0} seconds.'.format(sleep_duration))
            if sleep_duration > 0:
                time.sleep(sleep_duration)
            logging.info('Trying again...')
            response = self.send_post_request(payload, request_uri)
        elif response.status_code == MimecastResponseCodes.binding_expired:
            model = RefreshAccessKeyRequest(self.email, self.access_key)
            logging.info('Access key expired. Refreshing access key.')
            self.send_post_request(model.payload, MimecastEndpoints.refresh_access_key)
            logging.info('Access key refreshed.')
            response = self.send_post_request(payload, request_uri)
        return response
Sending POST requests to Mimecast API.
Solutions/MimecastAudit/Data Connectors/Helpers/request_helper.py