I want to create two Rest methods that vary based on the query string parameter in the URI.
like
[WebGet(UriTemplate = "Guest/{guestId}?day={day}&type={type}")]
[OperationContract(Name = "GetDetailByDayAndActivity")]
public GuestDetail GetDetail(string guestId, DateTime day, string type)
[WebGet(UriTemplate = "Guest/{guestId}?day={day}")]
public GuestDetail GetDetail(string guestId, DateTime day)
This gives the error:
"Operation 'GetDetailByDayAndActivity' in contract 'IRestService' has a UriTemplate that expects a parameter named 'TYPE', but there is no input parameter with that name on the operation. "
When accessing the method that has only the day parameter like: http://testserver/GuestService/Guest/0?day=2011-10-20
How can this be achieved?
Figured out the cause of this error.
The name of parameter in the Interface was different. The name used in the URI must match with then name in interface.
Moreover, there is no need to define separate methods if we are using query string. Single method would work, in this case other parameters will have null values.