Problem with http.post

Hi, I want to ask one question. I have problem with post request. My method in service looks like this

addSomething(number_0: string,number_1: string): Observable<any> {                                                                                 
    const token = this.getToken();                                                                                                         
  //  const body = JSON.stringify({ number_0: number_0, number_1: number_1                                                                
  //});                                                                                                                                  
    const headers = new Headers({'Content-Type': 'application/json', 'Accept':'application/json'});                                        
    return this.http.post('http://something/api/numbers?token=' + token,                                                              
        { number_0: number_0, number_1: number_1 }, {headers: headers});                                                                                                             
}

I tried with every possible solution but it doesn’t work. On back-end side I have CORS enabled. As you can see i tried with or without JSON.stringify() and it doesn’t work but for example this method works just fine.

signIn(email: string, password: string) {
        return this.http.post('http://something/api/user/sign', {email: email, password: password},
            {headers: new Headers({'X-Requested-With': 'XMLHttpRequest'})})
            .map(
                (response: Response) => {
                    const token = response.json().token;
                    const base64Url = token.split('.')[1];
                    const base64 = base64Url.replace('-', '+').replace('_', '/');
                    return {token: token, decoded: JSON.parse(window.atob(base64))};
                }
            )
            .do(
                tokenData => {
                    localStorage.setItem('token', tokenData.token);
                }
            );
    }

My response in console looks like this

.

Hi,
You problem is in the API, not in your code.

Axel thanks for reply but can you explain me why does all other POST routes like signIn and signUp work just fine?

Hi @Dule84
The API is throwing the error “INTERNAL SERVER ERROR”. The code for the “sign” service has problems. The API must return a JSON response always, but in this case it has a 500 code error.

Yes Axel, you were right! I didn’t have one field in that table in database so post request couldn’t insert values in correct way. Thanks once again.