WCF REST GET与JSON请求对象?

L-F*_*our 3 c# rest wcf json get

如果我定义GET操作如下:

 [OperationContract]
 [WebInvoke(UriTemplate = "/findcategories", Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
 FindCategoriesResponse FindCategories(FindCategoriesRequest request);
Run Code Online (Sandbox Code Playgroud)

但是当我尝试这个时,我得到了例外:

Operation 'FindCategories' in contract 'IComplaintService' uses GET, but also has body parameter 'request'. GET operations cannot have a body. Either make the parameter 'request' a UriTemplate parameter, or switch from WebGetAttribute to WebInvokeAttribute.
Run Code Online (Sandbox Code Playgroud)

在执行GET请求时,是否无法接受JSON对象作为参数?

谢谢

Dar*_*rov 7

在执行GET请求时,是否无法接受JSON对象作为参数?

不.使用GET请求,您可以使用查询字符串参数.如果要发送整个JSON对象,则应使用POST.