def _request(self, endpoint, params):
params["initial_app_strings"] = "geORNtsZe5I4lRGjG9GZiA"
if self.custom_sessionid:
params["custom_sessionid"] = self.custom_sessionid
else:
params["custom_sessionid"] = ""
req = Request('POST', url=BASE_URL + endpoint, data=params).prepare()
log.debug("invoking carwings API: %s" % req.url)
log.debug("params: %s" % json.dumps(params, sort_keys=True, indent=3, separators=(',', ': ')))
try:
sess = requests.Session()
response = sess.send(req)
log.debug('Response HTTP Status Code: {status_code}'.format(
status_code=response.status_code))
log.debug('Response HTTP Response Body: {content}'.format(
content=response.content))
except RequestException:
log.warning('HTTP Request failed')
j = json.loads(response.content)
if "message" in j and j["message"] == "INVALID PARAMS":
log.error("carwings error %s: %s" % (j["message"], j["status"]) )
raise CarwingsError("INVALID PARAMS")
if "ErrorMessage" in j:
log.error("carwings error %s: %s" % (j["ErrorCode"], j["ErrorMessage"]) )
raise CarwingsError
return j
评论列表
文章目录