I have an operation contract in an existing WCF service. Now I am extending it for WCF REST api and I am getting a lot of errors, the last one in the service is around parameters. My code is as below:
[OperationContract(Name = "Messages", IsOneWay = true)]
[WebInvoke(Method = "GET",
UriTemplate = "/Messages/?id={id}&fileId={fileId}",
ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped)]
[Description("Inbound Message")]
void Messages(Guid id, int fileId);
I am getting the error:
The UriTemplate '/Messages/?id={id}&fileId={fileId}' is not valid; each portion of the query string must be of the form 'name=value', when value cannot be a compound segment. See the documentation for UriTemplate for more details.*
Please suggest what am I missing in the uritemplate?
You need to remove
/before?fromUriTemplateand changeidparameter to string.See also: UriTemplate and UriTemplateTable