2014-11-06 7 views
1

컨트롤러 끝점의 경로에서 선택적 매개 변수를 정의하는 올바른 구문은 무엇입니까? 경로의 선택적 매개 변수를 정의하는 Web.Api

[Route("customers/{customerId}/boats/{boatId}/bookings{contractId?}&{startDate?}&{endDate?}&{outOnly?}", Name = "GetBookingsByBoat")] 
    [ResponseType(typeof (IEnumerable<BookingSummaryDTO>))] 
    public IHttpActionResult Get(int customerId, int boatId, int? contractId, DateTime? startDate, DateTime? endDate, bool outOnly = false) 
    { 

위의 컴파일

하지만

customers/40/boats/24/bookings 

를 사용하여 엔드 포인트를 시도하고 호출 할 때 내가 얻을 :

:

{"message":"The requested resource does not support http method 'GET'."} 

많은 감사

답변

0

는 솔루션입니다
[Route("customers/{customerId}/boats/{boatId}/bookings", Name = "GetBookingsByBoat")] 
    [ResponseType(typeof (IEnumerable<BookingSummaryDTO>))] 
    public IHttpActionResult Get(int customerId, int boatId, int? contractId = null, DateTime? startDate = null, DateTime? endDate = null, bool outOnly = false) 
관련 문제