在过去的几个小时里,我一直在用头撞墙,这就是我们正在尝试做的事情:一个方法需要一个原始/简单类型作为请求主体。最初我们尝试使用布尔值,但这不起作用,所以我们尝试使用字符串和对象。一样。
这是服务器端代码
[OperationContract]
[WebInvoke(UriTemplate = "/foo/{foo_id}/bar", Method = "POST", ResponseFormat=WebMessageFormat.JSON)]
string G(string foo_id, string content);
这是 Fiddler 中的请求:
标题:
User-Agent: Fiddler
Host: localhost
Content-Type: 'application/json',
Content-Length: 19
身体:
"hello_world"
我们尝试包装"hello_world"
一个 json 对象,例如 {"content":"hello_world"} 但没有运气。
有什么想法吗?