# Problem with http.post

**URL:** <https://forum.ionicframework.com/t/problem-with-http-post/140848>\
**Category:** Ionic Framework\
**Created:** [September 5, 2018, 3:08pm UTC](https://forum.ionicframework.com/t/problem-with-http-post/140848 "2018-09-05T15:08:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dule84](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@Dule84](https://forum.ionicframework.com/u/Dule84)\
**Post date:** [September 5, 2018, 3:08pm UTC](https://forum.ionicframework.com/t/problem-with-http-post/140848/1 "2018-09-05T15:08:47Z")

</div>

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

```auto
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.

```auto
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

 ![Capture2](https://global.discourse-cdn.com/ionicframework/original/3X/d/5/d5b31cd543adf99f7b70675a45fc30fa8f197951.jpeg) .

---

<div class="post-metadata">

**Author:** ![AxelStone](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/axelstone/32/121539_2.png) [@AxelStone](https://forum.ionicframework.com/u/AxelStone)\
**Post date:** [September 5, 2018, 11:28pm UTC](https://forum.ionicframework.com/t/problem-with-http-post/140848/2 "2018-09-05T23:28:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dule84](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@Dule84](https://forum.ionicframework.com/u/Dule84)\
**Post date:** [September 5, 2018, 11:34pm UTC](https://forum.ionicframework.com/t/problem-with-http-post/140848/3 "2018-09-05T23:34:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AxelStone](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/axelstone/32/121539_2.png) [@AxelStone](https://forum.ionicframework.com/u/AxelStone)\
**Post date:** [September 5, 2018, 11:38pm UTC](https://forum.ionicframework.com/t/problem-with-http-post/140848/4 "2018-09-05T23:38:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dule84](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@Dule84](https://forum.ionicframework.com/u/Dule84)\
**Post date:** [September 6, 2018, 1:19pm UTC](https://forum.ionicframework.com/t/problem-with-http-post/140848/5 "2018-09-06T13:19:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:17pm UTC](https://forum.ionicframework.com/t/problem-with-http-post/140848/6 "2021-07-19T21:17:58Z")

</div>

Closed on July 19, 2021, 9:17pm UTC


