【发布时间】:2017-08-22 06:37:17
【问题描述】:
我有以下代码可以使用请求模块发布
api_path = r'/DeviceCategory/create'
api_server = (self.base_url + api_path)
logging.info("Triggered API : %s", api_server)
arguments = {"name": "WrongTurn", "vendor": "Cupola", "protocolType": "LWM2M"}
headers = {'content-type': 'application/json;charset=utf-8', 'Accept': '*'}
test_response = requests.post(api_server,headers=headers,cookies=self.jessionid,
timeout=30, json=arguments)
logging.info(test_response.headers)
logging.info(test_response.request)
logging.info(test_response.json())
logging.info(test_response.url)
logging.info(test_response.reason)
我在标题中得到以下响应
2017-08-22 12:03:12,811 - 信息 - {'Server': 'Apache-Coyote/1.1', 'X-FRAME-OPTIONS': 'SAMEORIGIN, SAMEORIGIN', 'Access-Control-Allow-来源':'*','Access-Control-Allow-Methods':'GET,POST,DELETE,PUT','Access-Control-Allow-Headers':'Content-Type','Content-Type':' text/html;charset=utf-8', 'Content-Language': 'en', 'Transfer-Encoding': 'chunked', 'Content-Encoding': 'gzip', 'Vary': 'Accept-Encoding' , '日期': '星期二, 2017 年 8 月 22 日 06:33:12 GMT', '连接': '关闭'}
和JSON解码错误
从 None 提高 JSONDecodeError("Expecting value", s, err.value) json.decoder.JSONDecodeError:预期值:第 1 行第 1 列(字符 0)
有人能帮帮我吗,我得到的状态码是 500
【问题讨论】:
标签: json python-requests