ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
50.47k stars 13.53k forks source link

CapacitorHttp FormData Not Supported on Android Device but it working fine on ionic serve(browser) #29405

Closed mobiliseapplabllp closed 2 weeks ago

mobiliseapplabllp commented 2 weeks ago

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

when i hit api and using FormData, formData is empty on android device but it is working fine on browser

Expected Behavior

api should hit on both platform chrome and android and ios also when using FormData() and if i m using jsonObject then it is work fine

Steps to Reproduce

import { CapacitorHttp, HttpResponse } from '@capacitor/core';

// Post Function async postTest() { const formData = new FormData(); formData.append('username', 'superadmin'); formData.append('password', 'password'); formData.append('source', 'Mobile'); const doPost = async () => { const options = { url: environment.url1 + 'login', headers: { 'Accept': 'application/json', 'Access-Control-Allow-Origin': '*' }, data: formData, }; const response: HttpResponse = await CapacitorHttp.post(options); }; doPost(); }

Code Reproduction URL

NA

Ionic Info

// capacitor.config.ts import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = { appId: 'com.hseglobal.mbl', appName: 'HSE Global', webDir: 'www', plugins: { CapacitorHttp: { enabled: true, }, }, };

export default config;

//ionic and capacitor info "@angular/animations": "^17.0.2", "@angular/common": "^17.0.2", "@angular/compiler": "^17.0.2", "@angular/core": "^17.0.2", "@angular/forms": "^17.0.2", "@capacitor/android": "^6.0.0", "@capacitor/app": "6.0.0", "@capacitor/core": "6.0.0", "@capacitor/haptics": "6.0.0", "@capacitor/keyboard": "6.0.0", "@capacitor/status-bar": "6.0.0", "@ionic/angular": "^7.0.0",

Additional Information

No response

sean-perkins commented 2 weeks ago

Hello @mobiliseapplabllp this repository is for the UI components (Ionic Framework), not Capacitor. You should open a ticket on the Capacitor repository.

I would recommend creating a minimal reproduction with that report, as with the current information the team will likely not be able to root cause.