Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

POST Data is not passing (iOS) #251

Open
areanet-schmid opened this issue Apr 13, 2022 · 7 comments
Open

POST Data is not passing (iOS) #251

areanet-schmid opened this issue Apr 13, 2022 · 7 comments

Comments

@areanet-schmid
Copy link

I'm trying to do a simple post request on iOS.

const options = {
      url: SERVER_URL,
      headers: { 'Content-Type': 'application/json'  },
      data: { foo: 'bar', cool: true },
    };

Http.post(options);

SERVER_URL is a simple PHP script with:
var_dump($_POST);

POST data is not sending - see console log:
Bildschirmfoto 2022-04-13 um 11 43 25

Environment:

  • Ionic CLI 6.19.0
  • Capacitor CLI 3.4.3
  • @ionic/angular 6.0.14
  • @capacitor/ios 3.4.3
  • @capacitor-community/http 1.4.1

similar tickets
#208
#67

@nhh
Copy link

nhh commented Apr 26, 2022

We are experiencing this too. +1

@billpull
Copy link

@areanet-schmid are you only experiencing this on certain versions of iOS? I am testing a new app and users with iOS v14 are reporting issues that seem related.

@Gladiatornoshield
Copy link

Hi Guys any solution to this. I cant seems to get POST data on the server. But i can get data when using Postman. Any help would be grateful

This is the final item on my app and i really need a solution ASAP any help suggestions would be appreciated

image

@simonthesurgery
Copy link

simonthesurgery commented May 31, 2022

I've also encountered this issue.

Works fine in Chrome, but nothing is passed on iOS
Screenshot 2022-05-31 at 10 22 46

iOS 15.5
capacitor/core 3.4.3
capacitor/ios 3.4.3
capacitor-community/http 1.4.1
ionic/angular 6.0.0

@Gladiatornoshield
Copy link

I ended up using axios until I find a permanent solutions. Works well on both iOS and Android

@gpereira13
Copy link

gpereira13 commented Jun 1, 2022

I fixed this by setting the 'Content-Type' header to my request as reading the ios plugging relies in the content type to parse the body data.

See:

func getRequestData(_ body: [String: Any], _ contentType: String) throws -> Data? {

maybe we could specify that on the documentation

EDIT:
tested on IOS only

@mightytyphoon
Copy link

yeah the problem is known and I think pull requests were sent but there is absolutely no review by the maintainers. Create a http service with all requests inside and use axios, if one day capacitor http is finally working properly, you can add it by simply changing the http service and you won't have to change every requests in your app.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants