【问题标题】:REST API Post request - Request ErrorREST API 发布请求 - 请求错误
【发布时间】:2014-09-26 00:16:14
【问题描述】:

我有一个使用 post 方法的 REST API 调用。 WCF 服务又将输入字符串保存到数据库中。这是我的 WCF 合同

[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, UriTemplate = "/xxxx")]
int xxxx(string username);

当我在 chrome 上使用 DHC 客户端进行测试时,它会显示错误的请求错误。发送到服务器的 json 数据格式为 {"username": test123} 请在下面找到图片

发送到服务器的数据格式是否错误?请提出建议。

【问题讨论】:

    标签: wcf rest wcf-data-services


    【解决方案1】:

    合同应标有以下 WebInvoke 属性 - [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, UriTemplate = "/xxxx")]

    【讨论】:

      猜你喜欢
      • 2021-03-31
      • 1970-01-01
      • 2022-08-13
      • 1970-01-01
      • 1970-01-01
      • 2013-05-09
      • 2019-02-25
      • 1970-01-01
      • 2018-02-03
      相关资源
      最近更新 更多