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

Inconsistent results when calling API from different platforms #96

Closed
lukemovement opened this issue Feb 11, 2021 · 2 comments
Closed

Comments

@lukemovement
Copy link

I'm sure if this is an issue with the platforms, my backend (old framework), or this package.

When making an HTTP request with a body of data different configuration needs to be used for iOS and Android.

When using "application/x-www-form-urlencoded" with iOS results in the requests data being decoded automatically.
When using "application/json" with Android the requests data is empty.

The issues below resolve themselves when using "application/json" on iOS and "application/x-www-form-urlencoded" for Android.

To Reproduce
IOS:
{ url: string, method: "POST", data: { "email": "email+address@email.com" }, headers: { "Content-Type": "application/x-www-form-urlencoded" } }

The body received by the server { "email": "email address@email.com" }

Android:
Request { url: string, method: "POST", data: { "email": "email+address@email.com" }, headers: { "Content-Type": "application/json" } }

The body received by the server {}

Expected behaviour
Results should be consistent across platforms, where $_POST['email'] would return "email+address@email.com"

Smartphone: IOS

  • Device: Emulator
  • OS: iOS12, iOS12.4, iOS14.4
    (Apple tester also experienced this issue when testing the app before approving it for the App Store, the test on physical devices)

Smartphone: Android

  • Device: Emulator, Redmi Note 9, Samsung S6
  • OS: Android 6, 10
@thomasvidas
Copy link
Contributor

Hello 👋 Thanks for the issue. A couple questions.

Can you provide a sample project/server where the exact error is happening?
What version of Capacitor are you using?
What version of the HTTP plugin are you using?

@thomasvidas
Copy link
Contributor

Closing due to no response. Please re-open if this is still an issue 😄

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

No branches or pull requests

2 participants