我正在尝试使POST服务返回的列表Tienda
。我的代码如下所示:
[HttpPost]
[ResponseType(typeof(List<TiendaWrapper>))]
public IHttpActionResult GetTiendasPost([FromBody]Tienda t)
{
List<Tienda> ListaTiendas = db.Tiendas.ToList();
List<TiendaWrapper> lstTiendas = new List<TiendaWrapper>();
foreach(Tienda T in ListaTiendas)
{
if (T.CodDpto == t.CodDpto && T.CodRetail == t.CodRetail)
{
TiendaWrapper tiend = new TiendaWrapper(T);
lstTiendas.Add(tiend);
}
}
return Ok(lstTiendas);
}
但是,当我使用邮递员致电服务时,会遇到此异常。该函数应该接收两个Id作为主体,并找到Tiendas
具有这些Id的对象
"$id": "1",
"Message": "The request entity's media type 'multipart/form-data' is not supported for this resource.",
"ExceptionMessage": "No MediaTypeFormatter is available to read an object of type 'Tienda' from content with media type 'multipart/form-data'.",
"ExceptionType": "System.Net.Http.UnsupportedMediaTypeException",
任何帮助将是巨大的,在此先感谢您。
编辑:
这就是我在邮递员中调用该方法的方式:http:// localhost:1918 / api / tiendas / GetTiendasPost然后我将Body中的值添加为表单数据。
在HTTP请求中,您需要将Content-Type设置为: Content-Type: application/json
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句