Ⅰ.需求:新项目在原有项目增加功能,需调用原项目API接口
API接口需要传入json格式数据:遂
username = request.data.get('username')
password = request.data.get('password')
region_id = request.data.get('region_id')
language_id = request.data.get('language_id')
data_obj = {'jwt': False,
'username': username,
'password': password,
'region_id': region_id,
'language_id': language_id,
'notification_id': notification_id,
}
data_json = json.dumps(data_obj)
pure360_result = requests.post(url=pure360_host, json=data_json,
headers={Constant.x_token: Constant.x_token_value,
Constant.x_date: Constant.x_date_value})
Ⅱ.参数正确,API一直验证不通过,猜测是发送请求时的json数据有问题
遂修改
# data_json = json.dumps(data_obj) 此行注释掉,不将字典抓成json格式数据
pure360_result = requests.post(url=pure360_host, json=data_obj, # json直接传入json格式的字典对象
headers={Constant.x_token: Constant.x_token_value,
Constant.x_date: Constant.x_date_value})
Ⅲ.验证通过
{'error': {'code': 200, 'message': 'Success'}, 'data': {'user': {}}
3 comments
《小鸟凯瑟琳》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/72192.html
叼茂SEO.bfbikes.com
博主真是太厉害了!!!