capacitor icon indicating copy to clipboard operation
capacitor copied to clipboard

bug: CapacitorHttp plugin does not fully support content-types other than JSON.

Open dv-alan opened this issue 3 years ago • 2 comments

Bug Report

Capacitor Version

@capacitor/cli: 4.6.3
@capacitor/core: 4.6.3
@capacitor/android: 4.6.3 @capacitor/ios: 4.6.3

Platform(s)

Android iOS

Current Behavior

As of commit #6165 the resulting change created an incosistnecy in how data from the CapacitorHttp module is sent between iOS and Android. Where iOS is sending data correctly as a form with the proper content type, the Android counterpart is just performing a .ToString() on the data object passed by the developer. This removes any support for posting forms, especially forms with multi-part/form-data on an Android platform. And can confirm this when comparing the Android variant with the iOS variant against a .NET Core Web API.

For context, compare the methods setting the request data in both cases. iOS's set data and Android's set data. Further more, referring to the former capacitor-community/http plugin, most of which I assume is just adapted code, used to work perfectly in a production environment and handled all of the necessary request content-types. Kindly refer to this code snippet as it's a tried and tested scenario.

Expected Behavior

  1. The resulting request needs to be identitcal between iOS and Android. If in both scenarios both content types are forms, then this should be preserved.
  2. Android should be able to handle all types of content-types correctly, not json only.

dv-alan avatar Feb 15 '23 08:02 dv-alan

I think it could be related to https://github.com/ionic-team/capacitor/pull/6206

koraxos avatar Mar 08 '23 14:03 koraxos

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed. Please see the Contributing Guide for how to create a Sample App. Thanks! Ionitron 💙

ionitron-bot[bot] avatar Feb 14 '24 18:02 ionitron-bot[bot]

It looks like this issue didn't get the information it needed, so I'll close it for now. If I made a mistake, sorry! I am just a bot.

Have a great day! Ionitron 💙

Ionitron avatar Mar 01 '24 00:03 Ionitron

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Mar 31 '24 00:03 ionitron-bot[bot]