title: Unsupported media type ASP.NET Core Web API
body: <p>On the front-end i use Angular to collect som data from the form and send it to my server-side controllers. As the image shows below, i get the data ($scope.newData) on my controller and service, but when it reaches the server, i get the following error: "Unsupported media type" and my newData is empty.</p>
  
  <p><a href="https://i.stack.imgur.com/1g4nn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1g4nn.png" alt="Website console"></a></p>
  
  <p>My controller:</p>
  
  <pre><code>// Create new salesman
    $scope.addSalesman = function (newData) {
      console.log("Controller");
      console.log($scope.newData);
      myService.addNewSalesman($scope.newData).then(function (data) {
        console.log(data);
      }, function (err) {
        console.log(err);
      });
    };
  </code></pre>
  
  <p>My service:</p>
  
  <pre><code>addNewSalesman: function (newData) {
              console.log("service");
              console.log(newData)
              var deferred = $q.defer();
              $http({
                  method: 'POST',
                  url: '/api/Salesman',
                  headers: { 'Content-type': 'application/json' }
              }, newData).then(function (res) {
                  deferred.resolve(res.data);
              }, function (res) {
                  deferred.reject(res);
              });
              return deferred.promise;
          }
  </code></pre>
  
  <p>My Salesman model:</p>
  
  <pre><code>public class Salesman
      {
          public int SalesmanID { get; set; }
          public string FirstName { get; set; }
          public string LastName { get; set; }
          public string Gender { get; set; }
          public string BirthDate { get; set; }
          public int Phone { get; set; }
          public string Adress { get; set; }
          public string City { get; set; }
          public int Postal { get; set; }
          public string Role { get; set; }
      }
  </code></pre>
  
  <p>My server-side controller:</p>
  
  <pre><code>[Route("api/[controller]")]
  public class SalesmanController : Controller
  {
  
      private readonly DataAccess _DataAccess;
  
      public SalesmanController() 
      { 
          _DataAccess = new DataAccess(); 
      } 
  
      [HttpPost]
      public IActionResult PostSalesman([FromBody] Salesman newData)
      {
          return Ok(newData); 
      }
  </code></pre>