虽然下面的数据是由邮递员发送的,带有必要的标题,但我得到了正确的响应,状态代码为200。但是当我使用相同的数据点击python请求中的函数时,我从这一行``中得到“error.ValueError太多的值需要解包”。 数据:
[{
"phone_number": "data",
"notification_type": "data",
"is_success": true,
"amount": 58,
"account_no": "data"
}]
def serve_sms(self, data: dict):
token = self.token(sms_service=True)
header = {
"service-name": "service",
"service-key": settings.Service,
"Authorization": "TOKEN " + token
}
try:
requests.post(settings.SMS_SERVE_URL, data=data, headers=header)
except Exception as e:
core_log().debug("serve sms request error {}".format(e))
我尝试用json json=data
更改响应内部的“数据”,但在那里我得到了404的状态代码
更新0:完整跟踪
http://... /api-service-auth/
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): ....:80
DEBUG:urllib3.connectionpool:http://...:80 "POST /api-service-auth/ HTTP/1.1" 200 212
DEBUG:connect_core:serve sms request error too many values to unpack (expected 2)
看起来你的JSON格式是错误的。下面的代码为我工作
相关问题 更多 >
编程相关推荐