title: jQuery AJAX post to MVC Controller object -- request shows up null
body: <p>I know I'm missing something in the details here. </p>
  
  <h2>Problem</h2>
  
  <p>Despite Googling, trying examples, different formats, etc, the AJAX request that I send always is validated as having all fields empty, but not being null.</p>
  
  <p>I think I'm not sending things in the proper format for the controller to recognize it as an object but I'm not sure what.</p>
  
  <h2>Fiddler: What my request looks like</h2>
  
  <p>With some dummy data: </p>
  
  <p><img src="https://i.stack.imgur.com/SBWRB.png" alt="enter image description here"></p>
  
  <h2>Code: Model Class</h2>
  
  <pre><code>public class ContactUsMessage
  {
      public string Email { get; set; }
      public string Name { get; set; }
      public string PhoneNumber { get; set; }
      public string Message { get; set; }
  }
  </code></pre>
  
  <h2>Code: WebAPI Controller</h2>
  
  <pre><code>    [HttpPost]
      public HttpResponseMessage NewMessage(ContactUsMessage messageToSend)
      {
          if (messageToSend == null)
          {
              var sadResponse = Request.CreateResponse(HttpStatusCode.BadRequest, "Empty Request");
              return sadResponse;
          }
  
          var messageValidator = new ContactUsMessageValidator();
          var results = messageValidator.Validate(messageToSend);
          var failures = results.Errors;
          var sadString = "";
          if (!results.IsValid)
          {
              foreach (var error in failures)
              {
                  sadString += " Problem: " + error.ErrorMessage;
              }
              var sadResponse = Request.CreateResponse(HttpStatusCode.NotAcceptable, "Model is invalid." + sadString);
              return sadResponse;
  
          }
          else
          {
              SendContactFormEmail(messageToSend.Email, messageToSend.Name, messageToSend.PhoneNumber, messageToSend.Message);
  
          }
  </code></pre>
  
  <h2>Code: JavaScript on Page</h2>
  
  <pre><code>function sendSubmissionForm() {
  
      var dataObject = JSON.stringify(
          {
              messageToSend: {
                  'Email': $('#inpEmail').val(),
                  'Name': $('#inpName').val(),
                  'PhoneNumber': $('#inpPhone').val(),
                  'Message': $('#inpMessage').val()
              }
          });
  
      $.ajax({
          url: '/api/contactus/newmessage',
          type: 'POST',
          done: submissionSucceeded,
          fail: submissionFailed,
          data: dataObject
  
      });
  
  
  }
  </code></pre>