Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'TenantManagementWebApi.Entities.Tenant

前端 未结 1 1800
栀梦
栀梦 2021-01-28 00:46

I have the following error:

JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type \'Tenant

相关标签:
1条回答
  • 2021-01-28 01:28

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

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

    Replace

    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 }));
    
    0 讨论(0)
提交回复
热议问题