415不支持的媒体类型asp.net核心

编程入门 行业动态 更新时间:2024-10-23 12:33:38
本文介绍了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核心

本文发布于:2023-10-29 10:10:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539422.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不支持   核心   类型   媒体   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!