详情
我试图将文件从Postman发布到我创建的端点.但它给了我这个错误.我没有在邮递员中传递标题Content-Type
415 Unsupported Media Type
API
[Consumes("multipart/form-data")]
[HttpPost]
public async Task<IActionResult> SendEmail([FromBody]Entity entity)
{
try
{
return OK();
}
catch (Exception e)
{
throw e;
}
}
类
public class Entity
{
public List<IFormFile> Files { get; set; }
}
最佳答案
如果您正在发布表单数据,请尝试使用[FromForm]而不是[FromBody]作为方法参数.
相关文章
- asp.net-core-webapi - 415(不支持的媒体类型)angular 4 Post
- c# - 远程服务器返回错误:(415)不支持的媒体类型
- jquery - 415不支持的媒体类型从$.ajax调用WCF服务
- 415 Spring中不支持的媒体类型JAXB
- java - HTTP状态415 - 不支持的媒体类型
- 415不支持的媒体类型 - 在lightswitch 2012中的POST数据到OData服务
- java - Spring REST,JSON“无法处理托管/后向引用'defaultReference'”415不支持的媒体类型
- hibernate - Spring MVC:@ResponseBody,415不支持的媒体类型
转载注明原文:c# – 415不支持的媒体类型asp.net核心 - 代码日志