title: Angular 6 HTTP Client Post - Bad request
body: <p>I have the following problem.
  I have a server on which the API is, I send the request to the registration endpoint, but in response I get a 400 Bad Request error, stating that the name, surname, email etc must be filled out. The problem is that they are filled. I miss ideas anymore. My code:</p>
  
  <pre><code>import {Component} from '@angular/core';
  import {HttpClient, HttpHeaders} from '@angular/common/http';
  
  @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
  })
  
  export class AppComponent {
      title = 'Brak tytułu';
  
      constructor(private http: HttpClient) {
      }
  
      registerUser() {
          const config = {headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')};
          const user: User = {
              name: 'Pawel',
              surname: 'Tester',
              email: 'tester@wp.pl',
              password: 'loremipsum12',
              password_confirm: 'loremipsum12',
              event_id: 1,
          };
  
          this.http.post('https://myapiserver', user, config).subscribe((res) =&gt; {
                  console.log(res);
                  console.log(user);
              },
              error =&gt; {
                  console.log(error);
                  console.log(user);
              });
      }
  }
  
  interface User {
      name: string;
      surname: string;
      email: string;
      password: string;
      password_confirm: string;
      event_id: number;
  }
  </code></pre>
  
  <p>This code works fine, but he is angularJS</p>
  
  <pre><code>    // User create
  $scope.createUser = function()
  {
      var create_req = $rootScope.reqDefaults;
          create_req.method = 'POST';
          create_req.url = $rootScope.api+'/admin/user';
          create_req.data = $httpParamSerializerJQLike($scope.current);
          create_req.transformRequest = angular.identity;
  
      // Users list
      $http(create_req)
          .then(function(response){
              $location.path('/users');
              $.notify({
                  title: '&lt;strong&gt;Użytkownik utworzony.&lt;/strong&gt;',
                  message: $scope.current.name+' '+$scope.current.surname+' (ID: '+response.data.id+')'
              },{
                  type: 'success'
              });
              return true;
          }, function(response){
              $rootScope.rspError(response.data);
              return false;
          });
  };
  </code></pre>
  
  <p>If i send request to the register endpoint from Postman, all works fine, my user is register correctly :( I set content type to application/x-www-form-urlencoded.</p>