我正在尝试构建一个模型来接收来自 HTTPPOST 的数据。
该模型已收到并很好地填充 - 除了IList<harsta> harequest
它显示为计数为 1,但针对字段具有空值:
我的模型是:
public class HAR
{
public int api_version { get; set; }
public IList<harsta> harequest { get; set; }
public class harsta
{
public int ta_id { get; set; }
public string partner_id { get; set; }
public string partner_url { get; set; }
}
...
...
}
harrequest 的 Post 数据是(应该有 2 个条目):
[{"ta_id":97497,"partner_id":"229547","partner_url":"http://partner.com/deeplink/to/229547"},
{"ta_id":97832,"partner_id":"id34234","partner_url":"http://partner.com/deeplink/to/id34234"}]
PostMan 的屏幕截图显示了发送到控制器的表单编码数据:
Example Request (this is the example provided on the 3rd party website)
POST
http://partner-site.com/api_implementation/ha
BODY
api_version=4
&harequest=[{"ta_id":97497,"partner_id":"229547","partner_url":"http://partner.com/deeplink/to/229547"},{"ta_id":97832,"partner_id":"id34234","partner_url":"http://partner.com/deeplink/to/id34234"}]
&start_date=2013-07-01
...
&query_key=6167a22d1f87d2028bf60a8e5e27afa7_191_13602996000
我确定它没有映射到我的模型,因为我在这里设置模型的方式:
public IList<harsta> harequest { get; set; }
public class harsta
{
public int ta_id { get; set; }
public string partner_id { get; set; }
public string partner_url { get; set; }
}
我是否错误地设置了模型,以便从 POST 中的 harequest 字段接收 JSON 数据?