trying to POST json dictionary to C# WCF, when i invoke it HTTP Response 415. Someone can tell me whats 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(); }
Fiddle 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; charset=utf-8'. Server: Microsoft-IIS/7.5 X-Powered-By: ASP.NET Date: Thu, 29 Nov 2012 01:21:55 GMT Content-Length: 0