“混合参数”指的是Post请求参数中既有普通字符串参数,又有json格式的参数。如添加房源时post的参数:
首先我们需要登录系统才能够获取它的session,获取session后可以直接对单个接口进行测试。下面代码是测试“保存”房源接口:
#coding=utf-8 import requests import json data1 = { ‘Account‘:"System", ‘Password‘:"4a7d1ed414474e4033ac29ccb8653d9b" } s = requests.session() s.post(url=‘http://10.10.134.86:8083/Login/CheckLogin‘,data=data1) r=s.get(‘http://10.10.134.86:8083/Home/AccordionIndex‘) print(r.text) house={"XnewHouseCode":"","ErpHouseCode":"11302498","ErpHouseAddress":"318国道1881号222fsf路十弄22号楼1号房","ErpCode" :"131798","ErpDistrictName":"318国道1881号","Room":"2","Hall":"1","Thebalcony":"1","Area":"123","SumFloor" :"20","PlaceFloor":"1","HousekeeperNo":"","HousekeeperName":"","CustomserviceNo":"","CustomserviceName" :"","BrokerNo":"16ACCDAE-FF34-43AA-8FC4-991B898F2FF5","BrokerName":"李鸿坤","LendType":"1","AddName":"" ,"AddDate":"","EntrustMoney":0,"MonthMoney":0,"SeasonMoney":0,"HalfyearMoney":0,"YearsMoney":0,"Orientation" :None,"RecommendType":None,"HouseTitle":None,"Description":"","DecorationStyleCode":None,"DecorationStyleName" :None,"AreaCode":None,"BusinessAreaCode":None,"ModifyPerson":"","ModifyDate":None,"Characteristic":"" ,"RoomInfo":[],"HouseImage":[],"RoomImage":[]} data2={ ‘KeyValue‘:None, ‘houseJson‘:json.dumps(house), ‘houseassetallocationJson‘:‘[]‘, ‘roomsJson‘:‘[]‘ } r=s.post(url=‘http://10.10.134.86:8083/HouseModule/HouseInfo/Insert‘,data=data2) print(r.text)
上面代码先将houseJson参数值进行编码,然后再Post
时间: 2024-10-25 06:09:39