title: Pass JSON object to WebApi
body: <p>I'm trying to post data from my web page to my RegistrationController Api. I see it when I submit the form, but when I hit my breakpoint on the WebApi, the parameter 'pilot' is null. Can someone tell me what I need to do to get the data to pass from the web page over to the Registration ApiController?  </p>
  
  <p>I saw this <a href="https://stackoverflow.com/questions/27869763/how-to-post-an-object-to-webapi">post</a>, but it did not seem to work for me. This <a href="https://stackoverflow.com/questions/33895572/how-to-read-json-object-to-webapi">post</a>, which was close to my question, mentioned that the model needed to annotated, but still did not work for me.</p>
  
  <p>Button on cshtml page:</p>
  
  <pre><code>&lt;button id="submitRegistration" class="btn btn-lg btn-primary btn-block"  
      type="submit"&gt;Submit&lt;/button&gt;
  </code></pre>
  
  <p>Angular RegistrationController:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  'use strict';
  
  var sampleApp = angular.module('RegistrationApp', []);
  
  sampleApp.controller('RegistrationController', function ($scope, $http) {
      var registrationData = {
          "firstname": $scope.firstname,
          "lastname": $scope.lastname,
          "faaNumber": $scope.faaNumber
      };
  
      $('#submitRegistration').click(function () {
  
          registrationData = {
              FirstName: $scope.firstname,
              LastName: $scope.lastname,
              FAANumber: $scope.faaNumber
          };
  
         // When I hit this debugger, the data is good.
         debugger;
          $.post("api/registration",
                  JSON.stringify(registrationData),
                  function (value) {
                  $('#registrationMessage').append(value);
                  },
                  "json"
          );
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>WebApi RegistrationController Class:</p>
  
  <pre><code>public class RegistrationController : ApiController
  {
  // *********** Pilot is null when the breakpoint hits here ************
  public HttpResponseMessage Post([FromBody]PilotModel pilot)     
  {
      this.RegisterPilot(pilot);
  
      var response = Request.CreateResponse&lt;PilotModel&gt;(HttpStatusCode.Created, pilot);
  
      return response;
  }
  
  private string RegisterPilot(PilotModel pilot)
  {
      var result = string.Empty;
  
      ...
  
      return result;
  }
  }
  </code></pre>
  
  <p>Pilot Model:</p>
  
  <pre><code>[DataContract]
  public class PilotModel
  {
      [DataMember]
      public string FirstName { get; set; }
  
      [DataMember]
      public string LastName { get; set; }
  
      [DataMember]
      public string FAANumber { get; set; }
  }
  </code></pre>