Почему PostMan Rest Client выдает мне эту ошибку? - PullRequest
0 голосов
/ 09 апреля 2020

Я пытаюсь создать нового пользователя с помощью клиента POSTMAN REST, он выдаёт мне эту ошибку

{
    "message": "The request entity's media type 'text/plain' is not supported for this resource.",
    "exceptionMessage": "No MediaTypeFormatter is available to read an object of type 'CustomerDto' from content with media type 'text/plain'.",
    "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)"
}

Мой код ApiController

 [HttpPost]
        public IHttpActionResult CreateCustomer(CustomerDto customerDto)
        {
            if (!ModelState.IsValid)
                return BadRequest();

            var customer = Mapper.Map<CustomerDto, Customer>(customerDto);
            _context.Customers.Add(customer);
            _context.SaveChanges();

            customerDto.Id=customer.Id;

            return Created(new Uri(Request.RequestUri + "/" + customer.Id), customerDto);
        }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...