-
Notifications
You must be signed in to change notification settings - Fork 128
Description
follow up of issue : #674
When trying to upload apk to firebase app distribution with FirebaseAppDistributionApi it fails with 400 without proper error message on what is the issue in the request.
DetailedApiRequestError(status: 400, message: No error details. HTTP status was: 400.)
I checked with the google-api-python-client and the firebase app distribution api is working fine in python and APK has successfully uploaded to firebase.
I compared the curl request sent by the python client and googleapis.dart.
The critical differences are as follows
| Header | Python | dart |
|---|---|---|
| content-type | application/vnd.android.package-archive | multipart/related; boundary="314159265358979323846" |
| content-length | 18,935,247 (actual apk size) | 25,247,203 |
I experimented with the googleapis.dart and here are my findings
- The protocol mentioned in disovery apis is
simple with multipart set to true
"protocols": {
"simple": {
"multipart": true,
"path": "/upload/v1/{+app}/releases:upload"
}
}
- APK will get uploaded when using the
simpleUpload()indiscoveryapis_commons > api_requester.dart > ApiRequester - class > _request().- But it will use
simpleUpload()only ifbodyparameter in_request()isnull. - The
bodyparameter gets its value by JSON encoding therequestobject passed toupload()ingenerated > googleapis > firebaseappdistribution > v1.dart > MediaSource - class > upload()async.Future<GoogleLongrunningOperation> upload( GoogleFirebaseAppdistroV1UploadReleaseRequest request, core.String app, { core.String? $fields, commons.Media? uploadMedia, }) async { final body_ = convert.json.encode(request);
- Even if the requeset passed to upload has no paramentes passed , it will enocode as
"{}" - The
toJson()method inGoogleFirebaseAppdistroV1UploadReleaseRequestis non nullable
- But it will use
in short , to upload using
simpleUpload()thebody_should benull
- By default , the package tries to upload using
MultipartMediaUploader-class > upload()- Here the content type is chaneged to
multipart/related; boundary="314159265358979323846"and the content length is changed accordingly to combine Json data and encoded binary file.
. Are we supposed to use this for upload. The rest api in firebase mention only about binary as body. https://firebase.google.com/docs/reference/app-distribution/rest/v1/upload.v1.projects.apps.releases/upload#http-request
- Here the content type is chaneged to