title: Trying to get a JQuery Post to communicate with WCF, but the JSON data is not being accepted
body: <p>I am using the following JQuery\JavaScript code to communicate with a WCF 4 REST service.</p>
  <pre><code>&lt;script&gt;
  var serviceUrl = &quot;http://services.xiine.com/Xiine/Live/AccountService/rest/json/Login&quot;;
  var userInfo = {
      &quot;IsNotEncrypted&quot;:true,
      &quot;Password&quot;:null,
      &quot;UserName&quot;:null
  };
  
  var loginSuccess = function(data, textStatus, jqXHR){
  console.log(&quot;yay&quot;);
  };
  var loginError = function(){
  console.log(&quot;oh no&quot;);
  };
  
  $.post(serviceUrl , userInfo, loginSuccess);
  $.post(serviceUrl , loginSuccess);
  
  &lt;/script&gt;
  </code></pre>
  <p>I am trying to establish why it is that the service will correctly return a false value when I do not pass the user data:</p>
  <pre><code>$.post(serviceUrl , loginSuccess);
  </code></pre>
  <p>As opposed to when I do pass user data, at which point it gives a POST 400 (Bad Request) error.</p>
  <pre><code>$.post(serviceUrl , userInfo, loginSuccess);
  </code></pre>
  <p>I am sure it has to do with how the JSON object, userInfo, is being built or interpreted, and I can post Fiddler 2 or WireShark dumps, if that will help. Just let me know...</p>
  <p>I don't really have access to changing the WCF side of the service, so hopefully there is something I can do on my end to make this work.</p>
  <p>Thanks!</p>
  <p><em>Edit</em></p>
  <p>I got a little more information... Apparently, the problem is that the server is responding with the following error:</p>
  <blockquote>
  <p>The server encountered an error processing the request. The exception message is 'The incoming message &gt;has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', &gt;'Json'. This can be because a WebContentTypeMapper has not been configured on the binding. See the &gt;documentation of WebContentTypeMapper for more details.'. See server logs for more details. The &gt;exception stack trace is:</p>
  <p>at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.CompositeDispatchFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp; rpc) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&amp; rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</p>
  </blockquote>
  <p>So I am thinking I need to figure out how to get the object to go across the wire as a JSON object via a JQuery.post() method.</p>
  <p><em>More information --- Again...</em></p>
  <p>ok... There is no app.config or web.config, as such.</p>
  <p>Here is what I can get as far as the contracts and code and what-not.</p>
  <pre><code>[ServiceContract]
  public interface IAccount
  {
  [OperationContract]
  bool Login(UserInformation user);
  }
  
  [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
  [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  public class AccountService : IAccount
  {
  public bool Login(UserInformation user)
  {
      //stuff...
  }
  }
  
  [DataContract]
  public class UserInformation
  {
  [DataMember(IsRequired = true)]
  public string UserName;
  
  [DataMember(IsRequired = true)]
  public string Password;
  
  [DataMember(IsRequired = true)]
  public bool IsNotEncrypted;
  }
  
  public interface IUserInformation
  {
  UserInformation UserInformation { get; set; }
  }
  </code></pre>