本文介绍了415不支持的媒体类型asp核心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将文件从Postman发布到我创建的端点.但这给了我这个错误.我没有在邮递员中传递标头Content-Type
I am trying to post a file from Postman to the endpoint I have created. but it gives me this error. I am not passing the header Content-Type in postman
415不支持的媒体类型
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] 作为方法参数表单数据.
Try using [FromForm] instead of [FromBody] for the method parameter if you're POSTing form data.
更多推荐
415不支持的媒体类型asp.net核心
发布评论