# Rest api(POST Method) in ionic 2 not working on android device

**URL:** <https://forum.ionicframework.com/t/rest-api-post-method-in-ionic-2-not-working-on-android-device/90865>\
**Category:** ionic-v3\
**Created:** [May 18, 2017, 4:57pm UTC](https://forum.ionicframework.com/t/rest-api-post-method-in-ionic-2-not-working-on-android-device/90865 "2017-05-18T16:57:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kunal099](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/kunal099/32/109607_2.png) [@kunal099](https://forum.ionicframework.com/u/kunal099)\
**Post date:** [May 18, 2017, 4:57pm UTC](https://forum.ionicframework.com/t/rest-api-post-method-in-ionic-2-not-working-on-android-device/90865/1 "2017-05-18T16:57:05Z")

</div>

We are building an application in ionic 2 using API, api calls working fine on browser(used proxy Server) .

After android build(removed proxy server) GET method is working fine on device but POST method is not working. It is an API for user authentication so getting 403 forbidden error.

Below is the code:- Home.ts

```auto
this.authService.checkAuthentication().then((res) =>{
  console.log("Already authorized");
 this.data = res;
}, (err) => {
  this.data = 'error occured';
});

```

Auth.ts(Auth Provider)

```auto
checkAuthentication() {
    return new Promise((resolve, reject) => {
      let credentials = {
        email: 'test@test.com',
        password: 'password'
      };
      let headers = new Headers();
      headers.append('Content-Type', 'application/json');
        headers.append('X-XSRF-Token', 'kK4GDdiHAHejPeoXl4dL1AAgb13eiEwPhxvDw=');
      let options = new RequestOptions({ headers: headers });
      this.http.post(API_URL, JSON.stringify(credentials), options)
        .map(res => res.json())
        .subscribe((data) => {
          resolve(data);
        }, err => {
          reject(err);
        });
    });
  }

```

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [May 18, 2017, 4:57pm UTC](https://forum.ionicframework.com/t/rest-api-post-method-in-ionic-2-not-working-on-android-device/90865/2 "2017-05-18T16:57:49Z")

</div>

Please edit your post and use the `</>` button above the post input field to format your code or error message or wrap it in ````` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.

Did you remote debug the problem on the device already? Follow these instructions here to debug the problem in Chrome dev tools: [https://ionic.zone/debug/remote-debug-your-app#android](https://ionic.zone/debug/remote-debug-your-app#android) Look at the console and network tabs for errors.

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [May 18, 2017, 8:28pm UTC](https://forum.ionicframework.com/t/rest-api-post-method-in-ionic-2-not-working-on-android-device/90865/3 "2017-05-18T20:28:34Z")

</div>

Potential CORS issue, maybe?

---

<div class="post-metadata">

**Author:** ![saywhut](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@saywhut](https://forum.ionicframework.com/u/saywhut)\
**Post date:** [September 5, 2018, 5:32pm UTC](https://forum.ionicframework.com/t/rest-api-post-method-in-ionic-2-not-working-on-android-device/90865/4 "2018-09-05T17:32:55Z")

</div>

having the same issue here. I don’t see how it could be CORS since the GET works perfectly 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:06pm UTC](https://forum.ionicframework.com/t/rest-api-post-method-in-ionic-2-not-working-on-android-device/90865/5 "2018-09-05T23:06:29Z")

</div>

Hi  
You problem is in the backend, not in ionic.  
Remember that the POST values that send Angular are received in payload json format. Some backend frameworks require some customization to manage payload format.

---

<div class="post-metadata">

**Author:** ![saywhut](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@saywhut](https://forum.ionicframework.com/u/saywhut)\
**Post date:** [September 6, 2018, 2:10am UTC](https://forum.ionicframework.com/t/rest-api-post-method-in-ionic-2-not-working-on-android-device/90865/6 "2018-09-06T02:10:50Z")

</div>

Hi Alex, I was suspicious of our backend but not able to find the issue. what’s curious though is that iOS is going for all request types. It’s just Android blocking at 403 on POST. We have Cloud Front for content but that’s probably OK because images come through. we use keycloak for security and I’m wondering if that’s my issue? maybe Android doesn’t use localhost or /127.0.0.1/ ?

---

<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 6, 2018, 4:41pm UTC](https://forum.ionicframework.com/t/rest-api-post-method-in-ionic-2-not-working-on-android-device/90865/7 "2018-09-06T16:41:35Z")

</div>

Hi @saywhut  
did you checked if the “email” and “password” are received correctly in the backend?
