没有MediaTypeFormatter可用于读取“列表”类型的对象

时间:2018-09-11 15:30:17

标签: c# asp.net json rest

尝试使用此签名将json编码的数组发布到webapi控制器方法时...

[HttpPost]
[ODataRoute("({rowId})/Action")]
public ICollection<ResultClass> CreateNew([FromODataUri] int rowId, [FromBody] List<ParameterClass> parameterClass)
{
...

我收到此错误...

{
    "error": {
        "code": "",
        "message": "The request entity's media type 'application/json' is not supported for this resource.",
        "innererror": {
            "message": "No MediaTypeFormatter is available to read an object of type 'List`1' from content with media type 'application/json'.",
            "type": "System.Net.Http.UnsupportedMediaTypeException",
            "stacktrace": "   at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n   at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)"
        }
    }
}

我想念什么?我最近阅读了很多示例,这些示例发布了没有问题的数组数据。

0 个答案:

没有答案