2014-09-26 201 views
0

enter image description here我有一個使用post方法的REST API調用。 WCF服務inturn將輸入字符串保存到數據庫。這是我的WCF合同REST API發佈請求 - 請求錯誤

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

當我在chrome上使用DHC客戶端進行測試時,它顯示錯誤的請求錯誤。發送到服務器的json數據格式爲{「username」:test123} 請在下面找到圖片

發送到服務器的數據格式是否正確?請建議。

回答

0

合同應標明以下WebInvoke屬性 - [WebInvoke(方法= 「POST」,BodyStyle = WebMessageBodyStyle.WrappedRequest,ResponseFormat = WebMessageFormat.Json,RequestFormat = WebMessageFormat.Json,UriTemplate = 「/ XXXX」)]