internal method for handling request and response
        and raising an exception is http return status code is not success

        :rtype : response object from requests.post()

def _http_request(self, api, data, headers=None):
        """
        internal method for handling request and response
        and raising an exception is http return status code is not success

        :rtype : response object from requests.post()
        """
        if not headers:
            headers = {'Content-Type': 'application/json'}
        if not self._token_valid:
            self._token = self.get_token(self._app_name, self._username, self._password)
        response = requests.post(self._base_url + '/' + api, data=json.dumps(data),
                                 headers=headers)
        # raise an exception if the status was not 200
        logger.debug(json.dumps(data))
        logger.debug(response.text)
        response.raise_for_status()
        return response