【发布时间】:2012-01-13 12:24:48
【问题描述】:
我正在尝试使用 WCF Web Api(预览版 6)编写服务,该服务通过路由和 POST 正文传递参数。 (变量和方法名称更改以保护无辜者)
例如..
[WebInvoke(UriTemplate = "{routeVariableOne}/{routeVariableTwo}/StaticRoute/{postVariableOne}", Method = "POST")] 公共 ReturnClass AddToCollection(字符串 postVariableOne,字符串 routeVariableOne,字符串 routeVariableTwo) { //做事 }
所以,我想将 postVariableOne 数据发布到 url /Resource/routeVariableTwo/routeVariableTwo
当我尝试发布此内容时
{ "postVariableOne": "新值" }
接受:应用程序/json 内容类型:应用程序/json 内容长度:31
http://localhost/App/api/Resource/routeVariableOne/routeVariableTwo/StaticRoute
我收到响应 500/内部服务器错误。服务器在处理请求时遇到错误。有关更多详细信息,请参阅服务器日志。如果我省略了 json post 值,它至少会达到我的断点。
【问题讨论】:
标签: wcf-web-api