How to set The UriTepmlate Attr like that:
/FunctionName?{json_data}
because the person who is working With this web service whats to call that way
for example: http://localhost/xxx/service/Func?{"x":"aaa","y":"bbb"}
I tried that
[OperationContract]
[WebGet(UriTemplate = "/Func?{request}",
BodyStyle = WebMessageBodyStyle.Bare,
ResponseFormat = WebMessageFormat.Json)]
Result Func(string request);
than I get that err:
The UriTemplate '/Func?{request}' is not valid; each portion of the query string must be of the form 'name' or of the form 'name=value', where name is a simple literal. See the documentation for UriTemplate for more details. Parameter name: template
when I set that
[OperationContract]
[WebGet(UriTemplate = "/Func?request={request}",
BodyStyle = WebMessageBodyStyle.Bare,
ResponseFormat = WebMessageFormat.Json)]
Result Func(string request);
it is working fine but this is not what they want.
You can't set it this way. The reason for this is that the "?" in an URL signifies URL parameters will follow, and URL parameters are always of the form "name=value"
You can either do
[OperationContract]
[WebGet(UriTemplate = "/Func?request={request}",
BodyStyle = WebMessageBodyStyle.Bare,
ResponseFormat = WebMessageFormat.Json)]
Result Func(string request);
Or
[OperationContract]
[WebGet(UriTemplate = "/Func/{request}",
BodyStyle = WebMessageBodyStyle.Bare,
ResponseFormat = WebMessageFormat.Json)]
Result Func(string request);
If you do it like the last example your parameter request can ONLY be a string.