trying to use a POST json dictionary for C # WCF when I call its HTTP response 415. Someone might tell me what is wrong with my code.
object class
[DataContract] public class Class1 { [DataMember] public string AccNo; [DataMember] public string CompanyName; [DataMember] public string DocDate; }
IService1.cs
[OperationContract] [WebInvoke(Method = "POST", UriTemplate = "json/PostSalesOrderData", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)] string PostSalesOrderData(string data);
Service1.svc.cs
public string PostSalesOrderData(string data) { JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary<string, Class1> dict = serializer.Deserialize<Dictionary<string, Class1>>(data); return dict["Debtor"].AccNo.ToString(); }
Script details
HTTP / 1.1 415 Cannot process the message because the content type 'application / json; charset = utf-8' was not the expected type text / xml; encoding = UTF-8 '. Server: Microsoft-IIS / 7.5 X-Powered- By: ASP.NET Date: Thu, 29 Nov 2012 01:21:55 GMT Content-Length: 0
source share