我正在使用 Tornado 网络,我正在尝试使用 httpclient 发出 http 请求以将事件插入 Google 日历。但我总是收到 400 错误请求错误。你能帮我解决这个问题吗?谢谢!
event = {
'start': {
'date': '2012-07-11'
},
'end': {
'date': '2012-07-12'
},
}
body = urllib.urlencode(event)
http_client = tornado.httpclient.AsyncHTTPClient()
headers = {'Authorization':'Bearer '+access_token}
req = tornado.httpclient.HTTPRequest(url="https://www.googleapis.com/calendar/v3/calendars/primary/events?key="+self.settings["google_developer_key"],
method="POST",
body=body,
headers=headers)
http_client.fetch(req, callback=self.insert_event_response)
这是我得到的错误:
HTTPResponse(code=400,request_time=None,buffer=<io.BytesIO object at 0x1bb3470>,_body=None,time_info={},request=<tornado.httpclient.HTTPRequest object at 0x1ccc310>,effective_url='https://www.googleapis.com/calendar/v3/calendars/primary/events?key=AIzaSyAyy9M1HZ1nDMdBwGMPDLamhFkCB8iQEJ0',headers={'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Transfer-Encoding': 'chunked', 'Expires': 'Wed, 11 Jul 2012 03:19:29 GMT', 'Server': 'GSE', 'Cache-Control': 'private, max-age=0', 'Date': 'Wed, 11 Jul 2012 03:19:29 GMT', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Type': 'application/json; charset=UTF-8'},error=HTTPError('HTTP 400: Bad Request',))