def postOperation(url, apiKey, payload=''):
urlHeadersJson = {'content-type': 'application/json',
'X-Api-Key': '%s' % str(apiKey)}
try:
h = httplib2.Http('.cache',
disable_ssl_certificate_validation=True)
if payload is None:
logger.debug('POST: ' + url)
(response, content) = h.request(url, 'POST',
json.dumps(payload),
urlHeadersJson)
else:
logger.debug('POST: ' + url + ' <- Data: ' + str(payload))
(response, content) = h.request(url, 'POST',
json.dumps(payload),
headers=urlHeadersJson)
except Exception, e:
raise Exception('Got an error code: ', e)
return content
评论列表
文章目录