capacitor-community / http

Community plugin for native HTTP
MIT License
209 stars 136 forks source link

POST Data is not passing (iOS) #251

Open areanet-schmid opened 2 years ago

areanet-schmid commented 2 years ago

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:

similar tickets https://github.com/capacitor-community/http/issues/208 https://github.com/capacitor-community/http/issues/67

nhh commented 2 years ago

We are experiencing this too. +1

billpull commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

gpereira13 commented 2 years ago

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: https://github.com/capacitor-community/http/blob/a9103fecaba4d3d3b731b7f0fa7e939ec0c98b7f/ios/Plugin/CapacitorUrlRequest.swift#L46

maybe we could specify that on the documentation

EDIT: tested on IOS only

mightytyphoon commented 2 years ago

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.