ionic-team / vscode-extension

15 stars 0 forks source link

IONIC with CapacitorHttp and Http from capacitor-community send empty data with Android #138

Closed devartstudio closed 1 year ago

devartstudio commented 1 year ago

I have a problem in Android with CapacitorHttp and with Http from '@capacitor-community/http' .

The data sent to the server is empty, in the console log I can see the data, but the server don't receive any data. With other platforms (browser and ios) it works fine, but not in Android (emulator and device).

Please, any suggestions? This is my ionic info:

Ionic:
   Ionic CLI                     : 7.1.1 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 7.4.1
   @angular-devkit/build-angular : 16.2.3
   @angular-devkit/schematics    : 16.2.3
   @angular/cli                  : 16.2.3
   @ionic/angular-toolkit        : 10.0.0
Capacitor:
   Capacitor CLI      : 5.4.1
   @capacitor/android : 5.4.1
   @capacitor/core    : 5.4.1
   @capacitor/ios     : 5.4.1
Utility:
   cordova-res : not installed globally
   native-run  : 1.7.3
System:
   NodeJS : v18.17.1 (/usr/local/bin/node)
   npm    : 9.6.7
   OS     : macOS Unknown

Ionic api calls.

const options : HttpOptions= {
    url: "https://fakeapi.com/url",
    headers: {'Content-Type': 'multipart/form-data'},
    data: {nickname:"fakenickname",password:"fakepassword"}
};
const response: HttpResponse = await CapacitorHttp.post(options);

server calls log with iOs and browser (correct):

{"post":{"nickname":"fakenickname","password":"fakepassword"},"get":{"_":"2023-09-22T09:20:25.556Z"},"req":{"\/url":"","nickname":"fakenickname","password":"fakepassword"}}

server calls log with Android (NOT correct):

{"post":[],"get":{"_":"2023-09-21T17:53:24.196Z"},"req":{"\/url":""}}

in capacitor.config.ts CapacitorHttp is enabled

plugins: {
    CapacitorHttp: {
      enabled: true,
    },
   ...

thanks for your help

dtarnawsky commented 1 year ago

Sounds like you want to get some help over at @capacitor-community/http if you are using that plugin, or @capacitor-plugins if you are using the built in Capacitor plugin. This project is for the Visual Studio Code Ionic extension.

devartstudio commented 1 year ago

I tried both, same result