web测试:test过程中接口报错 "Object reference not set to an instance of an object."
"Object reference not set to an instance of an object."
对象引用未设置为对象的实例
可能原因:
1、参数类型传错,或少传参数;
2、前端业务需设置必填值,接口未获取到必填值;
3、接口内部报错;(计算报错,逻辑出错)
比如,一个供应商资料接口,/api/services/app/ContactSupplierManagement/Create
文档会给你所有参数名,及参数类型;

| ouId | integer($int32) [必须]-所属组织单元 ID | 
| ouId_OuName | string 所属组织:关联值_________________________________ | 
| contactCode | string 供应商编码 | 
| contactName | string 供应商名称 | 
| contactFullName | string 供应商全称 | 
| supplierTypeid | integer($int32) 供应商类型 | 
| contactTypeIdTValue | string 供应商类型:字典值___________________________ | 
| supplierClassid | integer($int32) 供应商分类 ID | 
| contactClassId_ClassName | string 供应商分类:关联值_______________ | 
| contactWorkPropertyId | [...] | 
| contactWorkPropertyIdTValue | string 供应商性质:字典值_____________ | 
| status | integer($int32) 状态 | 
| statusTValue | string 状态:字典值 | 
| paymentTermId | integer($int32) 付款条件Id | 
| priceMode | integer($int32) 取价方式 | 
| taxComputationMode | integer($int32) 计税方式 | 
| amountComputationMode | integer($int32) 计算方式 | 
| ficaOuId | integer($int32) 财务组织单元 ID | 
| ficaOuId_OuName | string 对应财务组织:关联值 | 
| mnemonic | string 助记码 | 
| supplierGradeid | integer($int32) 供应商等级 ID | 
| contactGradeIdName | string 供应商等级值 | 
| isSupplier | integer($int32) 是否供应商 | 
| isCustomer | integer($int32) 是否客户 | 
| taxCode | string maxLength: 50 minLength: 0 纳税登记号 | 
| opAreaId | integer($int32) 业务地区 | 
| opAreaId_AreaName | string 业务地区:关联值 | 
| adAreaId | integer($int32) 行政地区 | 
| adAreaId_AreaName | string TaxCode | 
| legalPerson | string maxLength: 50 minLength: 0 法人代表 | 
| regAddress | string maxLength: 200 minLength: 0 注册地址 | 
| manager | string maxLength: 50 minLength: 0 负责人 | 
| phone | string maxLength: 50 minLength: 0 电话 | 
| remark | string maxLength: 200 minLength: 0 备注 | 
| creditMgt | boolean 信用管理 | 
| id | integer($int32) | 
| taxRate | number($double) 税率 | 
| pirceDecimal | integer($int32) 结算价小数位数 | 
| amountDecimal | integer($int32) 结算金额小数位数 | 
实际调用时的参数:

{
    "ouId":1627,
    "contactCode":"3",
    "contactName":"2",
    "contactFullName":"22",
    "supplierTypeid":0,
    "supplierClassid":"",
    "contactWorkPropertyId":[
        0
    ],
    "status":1,
    "ficaOuId":"",
    "mnemonic":"",
    "supplierGradeid":0,
    "isSupplier":1,
    "isCustomer":0,
    "taxCode":"",
    "opAreaId":1674,
    "adAreaId":"",
    "legalPerson":"",
    "regAddress":"",
    "manager":"",
    "phone":"",
    "remark":"",
    "creditMgt":true,
    "id":0,
    "contactBanks_ChildTable":[
    ],
    "contactAddress_ChildTable":[
    ],
    "contactOu_ChildTable":[
    ],
    "paymentTermId":"",
    "priceMode":"",
    "taxComputationMode":"",
    "amountComputationMode":"",
    "pirceDecimal":2,
    "amountDecimal":2
}
报错原因: integer类型,传入了String类型,后端没有对类型做管控。空String传过去就会报错。
 
·

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号