c# – 使用JSON请求对象的WCF REST GET?
发布时间:2020-12-16 01:49:51 所属栏目:百科 来源:网络整理
导读:如果我定义GET操作如下: [OperationContract] [WebInvoke(UriTemplate = "/findcategories",Method = "GET",RequestFormat = WebMessageFormat.Json,ResponseFormat = WebMessageFormat.Json)] FindCategoriesResponse FindCategories(FindCategoriesReques
如果我定义GET操作如下:
[OperationContract] [WebInvoke(UriTemplate = "/findcategories",Method = "GET",RequestFormat = WebMessageFormat.Json,ResponseFormat = WebMessageFormat.Json)] FindCategoriesResponse FindCategories(FindCategoriesRequest request); 但是当我尝试这个时,我得到了例外: 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. 在执行GET请求时,是否无法接受JSON对象作为参数? 谢谢 解决方法
不.使用GET请求,您可以使用查询字符串参数.如果要发送整个JSON对象,则应使用POST. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |