我有一个需要三个参数的api,一个字符串(数据类型),一个类(eloanInput)和一个布尔值(isCluster)
public HttpResponseMessage getEloanExcel(string dataType, EloanInput eloanInput, bool isCluster = false)
{
var exportDataService = new ExportDataService();
var exportExcel = new ExportExcel(dataType);
var inputParams = new CaseSearch.EloanInput();
inputParams.SEARCH_TYPE = eloanInput.SEARCH_TYPE;
inputParams.COUNTY_ID = eloanInput.COUNTY_ID;
inputParams.TOWN_ID = eloanInput.TOWN_ID;
inputParams.HOUSE_TYPES = (eloanInput.HOUSE_TYPES[0] == "-1" && eloanInput.HOUSE_TYPES.Count() == 1) ? null : eloanInput.HOUSE_TYPES;
inputParams.HouseProject = (eloanInput.HouseProject[0] == "-1" && eloanInput.HouseProject.Count() == 1) ? null : eloanInput.HouseProject;
inputParams.PUB_START_DT = eloanInput.PUB_START_DT;
inputParams.PUB_END_DT = eloanInput.PUB_END_DT;
}
就像下面的图片一样:
在Postman中测试API时遇到问题,我使用键,值方法传递参数,只有eloanInput获取null,它没有获取传递给我的值,但是其他参数确实获取了值由邮递员。
[Key] [Value]
dataType 'Eloan'
eloanInput { "SEARCH_TYPE": 2,
"COUNTY_ID": "-1",
"TOWN_ID": "-1",
"PUB_START_DT": "2006/11/22",
"PUB_END_DT": "2006/12/15",
"HOUSE_TYPES": ["01", "02", "03"],
"HouseProject": [1, 2, 3, 4, 5],
"DONE_START_DT": "88",
"DONE_END_DT": "108",
"FLOOR_FROM": "1",
"FLOOR_TO": "18",
"BUILD_AREA_FROM": "2",
"BUILD_AREA_TO": "48",
"CASE_TYPE": [1, 2, 3, 4, 5],
"CASE_CATEGORY": [1, 2, 3, 4],
"CASENM_KEYWORD": "12"}
isCluster false
邮递员请求