"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傳過去就會報錯。
·