У меня есть веб-сервис, где люди могут отправлять POST-запросы с заголовками, но у одного из них есть content-type=application/hal+json
. Я получаю это сообщение об ошибке:
Status : 415 Unsupported Media Type
{
"Message": "**The request entity's media type 'application/hal+json' is not supported for this resource.**",
"ExceptionMessage": "No MediaTypeFormatter is available to read an object of type 'LinksBody' from content with media type 'application/hal+json'.",
"ExceptionType": "System.Net.Http.UnsupportedMediaTypeException",
"StackTrace": " at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)"
}
Когда я попробовал запрос POST с POSTMAN, но с content-type=application/json
, он работает.
Так что мой вопрос, возможно ли изменить заголовкииз POST-запроса кого-то еще? от application/hal+json
до приложения / json.
Я использую HttpResponseMessage Пост.
Спасибо.