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 as exception:
            exception.extra_message = "Call to " + self.base_url + request_uri + " failed."
            raise MimecastRequestError("Request call to Mimecast 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(math.ceil(15))
            logging.info("Trying again...")
            response = self.send_post_request(payload, request_uri)
        elif response.status_code == MimecastResponseCodes.binding_expired:
            logging.info("Access key expired.")
            raise MimecastRequestError("Access key expired.")
        return response
Sending POST requests to Mimecast API.
Solutions/MimecastTIRegional/Data Connectors/Helpers/threat_intel_feed_request_helper.py