Google Play 控制台 API return '收到无效的 JSON 负载。 \'track_config\' 处的未知名称 "versionCodes":找不到字段。

Google Play Console API return 'Invalid JSON payload received. Unknown name "versionCodes" at \'track_config\': Cannot find field.'

我正在使用 Ionic、Cordova 和 Angular 开发一个项目,现在我正在发布过程中,需要使用 Google Play Console API 将其自动化,我发布了第二个应用程序版本,我正在使用 Python3 以及 oauth2client 和 httplib2 库来上传 APK。

我正在使用此 repository 的变体以适应 python3 并且我生成了访问 API 的凭据但是当我 运行 脚本到上传 APK 时出现以下错误:

googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/androidpublisher/v3/applications/com.somepackage.here/edits/ID_VERSION/tracks/beta?alt=json returned "Invalid JSON payload received. Unknown name "versionCodes" at 'track_config': Cannot find field.". Details: "[{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'track_config', 'description': 'Invalid JSON payload received. Unknown name "versionCodes" at 'track_config': Cannot find field.'}]}]">

我的代码如下所示:

track_response = service.edits().tracks().update(
    editId=edit_id,
    track=TRACK,
    packageName=package_name,
    body={u'versionCodes': [apk_response['versionCode']]}).execute()

我真的确定问题出在这里。

我一直在一些网站上寻求帮助,但似乎没有记录,我找到了一个相关的解决方案,但找到了 here 中的 Java 库。

如果你能帮助我,我将不胜感激。

我遇到了同样的问题,在阅读 API 文档后,我找到了这个解决方案:

    track_response = service.edits().tracks().update(
        editId=edit_id,
        track=TRACK,
        packageName=BUNDLE_ID,
        body={
            "track": TRACK,
            "releases": [
                {
                    "name": APP_NAME,
                    "versionCodes": [apk_response['versionCode']],
                    "status": "completed"
                 }
            ]
        }
    ).execute()