Json Post запрос на asp.net веб-api не работает
Эй, ребята, у меня есть as.net приложение web api с этим контроллером:
// GET: api/Events/5 [ResponseType(typeof(EventDto))] public async Task<IHttpActionResult> GetEvent(int id) { var events = await db.Events.Include(e => e.Name).Select(e => new EventDto() { Id = e.Id, Name = e.Name, Project = e.Project, Objectives = e.Objectives, City = e.City, Country = e.Country, EventStart = e.EventStart, Departure = e.Departure, Arrival = e.Arrival, Registration = e.Registration, NationalTransportation = e.NationalTransportation, Accommodation = e.Accommodation, AcNumberNights = e.AcNumberNights, AcPreferHotel = e.AcPreferHotel, AcPreferHotelUrl = e.AcPreferHotelUrl, Flight = e.Flight, FlDeparture = e.FlDeparture, FlDepartPrefer = e.FlDepartPrefer, FlDepartPreferUrl = e.FlDepartPreferUrl, FlReturn = e.FlReturn, FlRetPrefer = e.FlRetPrefer, FlRetPreferUrl = e.FlRetPreferUrl, Notes = e.Notes, Files = e.Files, Status = e.Status }).SingleOrDefaultAsync(e => e.Id == id); if (events == null) { return NotFound(); } return Ok(events); }
и я использую расширение postman chrome, чтобы проверить его с помощью этого json:
{ "Name": "psilva", "Project": "a", "Objectives": "s", "City": "a", "Country": "s", "EventStart": 2012, "Departure": 2012, "Arrival": 2012, "Registration": "a", "NationalTransportation": "a", "Accommodation" : "a", "AcNumberNights": 1, "AcPreferHotel": "a", "AcPreferHotelUrl": "a", "Flight": "a", "FlDeparture": 2012, "FlDepartPrefer": "a", "FlDepartPreferUrl": "a", "FlReturn": 2012, "FlRetPrefer": "a", "FlRetPreferUrl": "a", "Notes": "a", "Files": "a", "Status": "a" }
и я получу это от почтальона:
{ "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 'Event' 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.Net.Http.HttpContentExtensions.ReadAsAsync(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)" }
есть идеи, почему?