NativeScript / nativescript-background-http

Background Upload plugin for the NativeScript framework
Apache License 2.0
102 stars 50 forks source link

Only Android: Uncaught (in promise): Error: Cannot convert number to Ljava/lang/String; at index 1 #249

Closed AklsKiu closed 4 years ago

AklsKiu commented 4 years ago

JS: ERROR Error: Uncaught (in promise): Error: Cannot convert number to Ljava/lang/String; at index 1 JS: Error: Cannot convert number to Ljava/lang/String; at index 1 JS: at getMultipartRequest (file:///node_modules/nativescript-background-http/background-http.js:261:0) JS: at Function.push.../node_modules/nativescript-background-http/background-http.js.Task.createMultiPart (file:///node_modules/nativescript-background-http/background-http.js:162:0) JS: at Session.push.../node_modules/nativescript-background-http/background-http.js.Session.multipartUpload (file:///node_modules/nativescript-background-http/background-http.js:132:0) JS: at file:///src/app/services/rest/rest.service.ts:232:25 JS: at new ZoneAwarePromise (file:///node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:902:0)

kriefsacha commented 4 years ago

I have the same with " Cannot convert object to Ljava/lang/String; at index 0". Did you find a solution @AquilesOliveira

romulowspp commented 4 years ago

I think that this problem happen when you try to pass a non string value in parameter.

const params = [ { name: 1, value: 1 }, { name: "fileToUpload", filename: this.file, mimeType: 'image/jpeg' }];

https://github.com/NativeScript/nativescript-background-http/blob/a6267536a9c0b4efbf65f533decbcc841cd0af93/src/background-http.android.ts#L290

I will test more to make sure that this is the problem.

AklsKiu commented 4 years ago

I have the same with " Cannot convert object to Ljava/lang/String; at index 0". Did you find a solution @AquilesOliveira

The quickest and simplest solution is to form the string variable as @romulowspp said and until the correction comes out, I'm using it this way.

Thanks @romulowspp!!!!

zbranzov commented 4 years ago

The fix is released in nativescript-background-http@4.2.1