错误是
""消息":"请求包含实体主体但没有Content-Type标头。推断的媒体类型' application / octet-stream'此资源不支持。",
" ExceptionMessage":"没有MediaTypeFormatter可用于读取类型' Expression`1 []'来自媒体类型的内容' application / octet-stream'。", " ExceptionType":" System.Net.Http.UnsupportedMediaTypeException",
"堆栈跟踪":"在System.Net.Http.HttpContentExtensions.ReadAsAsync [T](HttpContent内容,类型类型,IEnumerable
1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable
1格式化程序,IFormatterLogger formatterLogger,CancellationToken cancellationToken)"}
我的代码:
public class ParticipantEventController : ApiController
{
private readonly IParticipantEventRepository repository;
public ParticipantEventController()
{
repository = new ParticipantEventRepository();
}
[Route("api/EventDetails/{EventId}")]
[HttpGet]
public IEnumerable<EventDTO> GetEventDetails(Guid EventId, params Expression<Func<Event, object>>[] includeProperties)
{
IEnumerable<Event> participantevent = repository.FindbyEvent(EventId,x=>x.Id,x=>x.Contents,x=>x.EventRegisteration).ToList();
var eventdb = Mapper.Map<IEnumerable<EventDTO>>(participantevent);
return eventdb;
}
}