python做post接口测试,请求参数包含数组、嵌套字典
在请求时需要在数组、嵌套的字典前面需要加上json.dumps([]),进行序列化
否则获取不到请求参数的值,提示xxx is required
{"issue":"xxxx","prize":xxx,"device":"xx","orders":{"xxxx":1},"tickets":[{"way_id":xxx,"bills":["0","1"],"position":[],"num":5,"tag":"xxxxxx","coefficient":1,"mode":1,"price":2}],"stops":1}
data = {"issue": "xxxx", "prize": xxxx, "device": "h5", "orders": json.dumps({"xxxx": 1}), "tickets": json.dumps([{"way_id": xxxx, "bills": ["0", "1"], "position": [], "num": 5, "tag": "xxxx", "coefficient": 1, "multiple": 1, "price": 2}]), "stops": 1}
res = requests.post(url, data, headers=request_head)