入参:application/json格式
{"district":"","activityId":"","city":"闵行区","districtId":0,"channel":"JIOS","payMethod":1,"provinceId":0,"ShopId":"38","province":"上海市","cityId":0,"pageIndex":1,"Products":"[\n {\n \"ActivityId\" : \"\",\n \"ProductId\" : \"TR-BS-TECHNO\",\n \"InstallShopId\" : \"\",\n \"ServiceId\" : \"\",\n \"Quantity\" : 2,\n \"VariantId\" : \"15\",\n \"InstallShop\" : \"\"\n },\n {\n \"ActivityId\" : \"\",\n \"InstallShopId\" : \"38\",\n \"ServiceId\" : \"FU-TUHU-LUTAI|1\",\n \"ProductId\" : \"FU-TUHU-LUTAI\",\n \"VariantId\" : \"1\",\n \"Quantity\" : 2,\n \"InstallShop\" : \"(仙霞小周)\"\n },\n {\n \"Quantity\" : 1,\n \"ProductId\" : \"FU-TUHU-MFQCJC\",\n \"ActivityId\" : \"\",\n \"InstallShopId\" : \"38\",\n \"InstallShop\" : \"(仙霞小周)\",\n \"VariantId\" : \"1\",\n \"ServiceId\" : \"FU-TUHU-MFQCJC|1\"\n }\n]","orderType":"Tires","isInstall":"true"}
①转义字符存在“”,与前面的“”重复,转成’单引号
②去掉\n
遇到中文报错用 :ensure_ascii=False
ori_data = {'LatBegin': '31.13584041936424', 'PromotionCode': '','black_box': 'eyJ0b2tlbklkIjoiOStHTGhOSXJyREJ1NzhPQUNHM3U4c1JtSFwvWW9mRk1XaUVJUlBFOHdmbnRraWU0anU3Y3I5WFl2M0RLS3hDM1Ywb3U2T21Gd21uNVpQVVVBelZROVhRPT0iLCJvcyI6ImlPUyIsInNlcUlkIjoiMTU5MTg0Njk5MzQyMDY5NTM5MSIsInByb2ZpbGVUaW1lIjo2MjQsInZlcnNpb24iOiIzLjIuNCJ9','BookType': 1, 'LngBegin': '121.40297080079473', 'activityId': '', 'IsTirePressure': False,'Type': 'Tire','LabelType': 3, 'Channal': 'TongDunIos','OrderList': [{'Quantity': 2, 'ProductId': 'TR-MP-CVC6', 'ActivityId': '', 'VariantId': '11'},
{'ProductId': 'FU-TUHU-MFQCJC', 'VariantId': '1', 'ActivityId': '', 'Quantity': 1}],'Name': '途虎测试1','DefaultAddress': {'City': '上海市', 'Cellphone': '18916207417', 'DistrictID': 35, 'Street': '','StreetId': 0,'Consignees': '途虎测试1', 'CityID': 1, 'AddressDetail': 'Fvhhhh', 'District': '黄浦区','ProvinceID': 0, 'Province': '上海市'}, 'OrderChannel': 'JIOS','Cellphone': '18916207417','PayMothed': 4,'DefaultCar': {'InsuranceRouter': '\\\/webView?url=https%3a%2f%2fwx.tuhu.cn%2freact%2fcarInsurance%2findex.html','StandardTireSize': '205\\\/55R16;195\\\/65R15;205\\\/50R17', 'Status': -1, 'Brand': 'D - 大众','IsTransferInOneYear': False, 'PropertyList': [], 'SalesName': '2015款 1.6L 手自一体 豪华版','CarTypeDescription': '大众 朗逸 1.6L 2019年产 2015款 1.6L 手自一体 豪华版', 'Pailiang': '1.6L','TID': '16299','ImageUrl': 'https:\\\/\\\/img1.tuhu.org\\\/Images\\\/Logo\\\/dazhong.png','CarID': 'acdd768b-1858-460f-a37a-0c412e413186', 'LastChangedDate': '2020-06-09 16:21:30','CarName': '朗逸', 'OdometerUpdatedTime': '2020-06-09 13:51:59', 'ProductID': 'VE-DDZLYSJDZ','IsShowCertificationInfo': True, 'IsDefaultCar': True, 'BrandType': '上海大众', 'OnRoadMonth': '','TireSizeForSingle': '205\\\/55R16', 'Nian': '2019','TireSize': '205\\\/55R16;195\\\/65R15;205\\\/50R17', 'LastBaoYangKM': 0, 'Vehicle': '朗逸-上海大众'},'UseIntegral': 'false', 'ShopId': '38', 'IsStockOut': False, 'ArrivalTime': ''}
ori_data["OrderList"][0]["Quantity"] =quantity
ori_data["OrderList"][0]["ProductId"] =product_id
ori_data["OrderList"][0]["ActivityId"] =activity_id
ori_data["OrderList"][0]["VariantId"] =variant_id
jsonStr= json.dumps(ori_data, ensure_ascii=False)
data={"jsonStr": jsonStr
}
response= request(method="post", url=url, headers=headers, json=data, verify=False)