【发布时间】:2018-06-14 17:03:40
【问题描述】:
我正在尝试使用 AWS 发送 POST 请求。我的问题是我不断收到错误 400:错误请求。非常感谢任何帮助!
url = 'https://api.samanage.com/incidents.json' # Set destination URL here
post_fields = {
'incident': {
'name': 'practice tickets for alexa',
'priority': 'LOW',
'requester': {
'email': 'example@samanage.com'
}
}
} # Set POST fields here
headers = {
'cookie': 'rbzid=OquMLWfcbKxn7DHPYXDBAb6%2Bg%2FS7%2FMkG5RPBxCSy5tRDToqbLchk3q4HUPyH%2FFJ1ykIrbT7gAhVigPk9n8dmrt%2BxzZwOnF5g9Gby2ljY%2FGk%3D',
'content-type': 'application/json',
'x-samanage-authorization': 'Bearer **Token**',
'accept': 'application/vnd.samanage.v2.1+json'
}
request = Request(url, urlencode(post_fields).encode(), headers=headers)
json = urlopen(request).read().decode()
print(json)
【问题讨论】:
-
另外值得注意的是,如果我完全取出标题,则会收到 401 Unauthorized 错误代码
标签: json python-3.x post httprequest