That's because we process the request body inside the action, without invoking a media-type formatter. And I believe you can only post one element at a time, so you shouldn't have an array in the request JSON either. In JSON Verbose request payloads there should not be a "d" outer element. The IsMultipartContent method checks whether the request contains a multipart MIME message. Start with our free trials. Make a GET HTTP call to Controller without Content-Type headder; 415 Unsupported Media Type is returned; Downgrade to 3.0 and the above steps return 200. 01/20/2014; 4 minutes to read +4; In this article. A media type, also called a MIME type, identifies the format of a piece of data. Internet Media Types. Yes, it is making progress :). Refer to this site for how to set Content-Type. Media Formatters in ASP.NET Web API 2. If a suitable input formatter is not setup, server will return 415 (Unsupported Media Type) response. GetParameter(StringSegment) Gets the parameter parameterName of the media type. There's no easy way to simply retrieve raw data to a parameter in an API method, so a few extra steps are provided using either manual handling of the raw request stream, or by creating custom formatter that can handle common 'raw' content types in your APIs via standard Controller method parameters. thanks for your help so far. type UnsupportedMediaTypeResult = class inherit StatusCodeResult Public Class UnsupportedMediaTypeResult Inherits StatusCodeResult Inheritance I have ASP.Net Core 2.1 API.It looks as below. IsSubsetOf(MediaType… [HttpPost] public async Task Post([FromBody]string email) { } When calling from the postman, I had to call the above API as below with the header set as Content-Type = application/json SoapUI w/ASP.NET and "415 Unsupported Media Type" Hi All, I'm trying to connect to a site that's running a ASP.NET server using SoapUI and no matter what I try, the only response I get back is: In HTTP, media types describe the format of the message body. Creates an Microsoft.AspNetCore.Mvc.Formatters.Internal.MediaTypeSegmentWithQuality containing the media type in mediaType and its associated quality. GetEncoding(String) GetEncoding(StringSegment) GetParameter(String) Gets the parameter parameterName of the media type. GET and DELETE should not require Content-Type I do not know if this is related to a similar core 2.2 bug dotnet/aspnetcore#4396 even though I am currently using core 2.1 To fix the unsupported media type I had to use HttpRequestMessage and add header to accept json with MediaTypeWithQualityHeaderValue like bellow. If it's meant to be a value from query, you need to add a FromQuery on the action parameter. New here? This is for responses only. To demonstrate this, comment out the line that adds input formatter and try POST: Removing Formatters 遇到几次使用Idhttp 进行接口请求的时候报错 http 415 unsupported media type 的错误。最后的解决办法几乎都是一样的。 设置Idhttp.ContentType 的类型。如 接口要求使用Post方式Json格式的串则设置: Idhttp.ContentType = 'application/json'. ASP.NET Core表单POST导致HTTP 415 Unsupported Media Type响应怎么办? 内容来源于 Stack Overflow,并遵循 CC BY-SA 3.0 许可协议进行翻译与使用 回答 ( 2 ) When posting raw body content to ASP.NET Core the process is not very self-explanatory. The problem was with the headers. Join a community of over 2.6m developers to have your questions answered on 415 Unsupported Media type on REST .net Core of Reporting Reporting. by Mike Wasson. Is GetModel a complex type?ApiController assumes complex types come from the body. What is on Mozilla's site on how to set 'Content-Type' header to … This tutorial shows how to support additional media formats in ASP.NET Web API. 第一步:先确定Unsupported Media Type是什么意思不支持的媒体类型(Unsupported media type)简单说就是你传输的json和后台接收到的匹配不上,类型不匹配那么问题... 博文 来自: z944395433的博客 If not, the controller returns HTTP status code 415 (Unsupported Media Type). When sending data to server, Content-Type header specifies the type of data in HTTP body.