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() in discoveryapis_commons > api_requester.dart > ApiRequester - class > _request().
- But it will use
simpleUpload() only if body parameter in _request() is null.
- The
body parameter gets its value by JSON encoding the request object passed to upload() in generated > 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 in GoogleFirebaseAppdistroV1UploadReleaseRequest is non nullable
in short , to upload using simpleUpload() the body_ should be null
- 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
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.
I checked with the
google-api-python-clientand 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
I experimented with the
googleapis.dartand here are my findingssimple with multipart set to truesimpleUpload()indiscoveryapis_commons > api_requester.dart > ApiRequester - class > _request().simpleUpload()only ifbodyparameter in_request()isnull.bodyparameter gets its value by JSON encoding therequestobject passed toupload()ingenerated > googleapis > firebaseappdistribution > v1.dart > MediaSource - class > upload()"{}"toJson()method inGoogleFirebaseAppdistroV1UploadReleaseRequestis non nullableMultipartMediaUploader-class > upload()multipart/related; boundary="314159265358979323846"and the content length is changed accordingly to combine Json data and encoded binary file.