Bad credentials while using HttpClient Post

i have REST API in symfony 3.4 with lexikjwt authentication and FOS bundle. When i do a post request to :

curl -X POST http://127.0.0.1:8000/login_check -d _username=username -d _password=password

a token is generated correctly as expected. Also when i enter the username and password in localhost:8000/login, a token is also generated.So the API is working. But when i try to send a request from my angular 2 frontend using HttpClientModule using this code :

 let body = new HttpParams();
   body.set('_username',username);
   body.set('_password',password);
   let headers = new HttpHeaders().append('Content-Type','application/x-www-form-urlencoded');
   this.http.post('http://localhost:8000/login_check',{body},{headers : headers}).subscribe(data => {
   console.log(data);

I have an error {{code : 401 ,message : "Bad credentials"}}. But When i use a generated token to make a GET request :

let headers = new HttpHeaders().append('Authorization','Bearer Some_token');
this.http.get('http://localhost:8000/api/mydata',{headers : headers}).subscribe(data => { console.log(data)

I got the right Json response.

My nelmio_cors config:

nelmio_cors:
    defaults:
        allow_credentials: false
        allow_origin: []
        allow_headers: []
        allow_methods: []
        expose_headers: []
        max_age: 0
        hosts: []
        origin_regex: false
    paths:
          '^/api/':
                        allow_origin: ['*']
                        allow_headers: ['*']
                        allow_methods: ['POST', 'PUT', 'GET', 'DELETE','OPTIONS']
                        max_age: 3600
          '^/':
                        origin_regex: true
                        allow_origin: ['*']
                        allow_headers: ['*']
                        allow_methods: ['POST', 'PUT', 'GET', 'DELETE','OPTIONS']
                        max_age: 3600

I wonder why my post request is not working. I tried to look an answer to this but to no avail.