且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法将当前JSON数组(例如[1,2,3])反序列化为类型'TenantManagementWebApi.Entities.Tenant

更新时间:2021-09-15 21:58:50

您的型号字符串表示形式发布,不是 JSON

await modelContent.ReadAsStringAsync()将以数组表示法返回一个字符串: [object Object]

Your model gets posted in its string representation, which is not JSON.
await modelContent.ReadAsStringAsync() will return a string in array-notation: [object Object].

您必须自己处理JSON序列化。

You'll have to take care of the JSON serialization yourself.

替换

data.append("model", { "TenantId": this.state.TenantId, "TenantUrl": this.state.TenantUrl, "TenantPassword": this.state.TenantPassword });

with

data.append("model", JSON.stringify({ "TenantId": this.state.TenantId, "TenantUrl": this.state.TenantUrl, "TenantPassword": this.state.TenantPassword }));