Google Play Console API返回“接收到无效的JSON负载”。“track\u config\”处的未知名称“versionCodes”:找不到字段

2024-10-03 02:36:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我在爱奥尼亚、科尔多瓦和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库相关的解决方案

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


Tags: namecomapiconfigfieldheretrack变体
1条回答
网友
1楼 · 发布于 2024-10-03 02:36:46

我也有同样的问题,在阅读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()

相关问题 更多 >