我正在Ionic,Cordova和Angular中从事一个项目,现在我正在发布过程中,需要使用Google Play Console API对其进行自动化,我发布了第二个应用程序版本,并且正在使用Python3和oauth2client和httplib2库以上传APK。
我使用的是repository的变体,适用于python3,我生成了访问API的凭据,但是当我运行脚本上传APK时,出现以下错误:
googleapiclient.errors.HttpError:请求时
https://www.googleapis.com/androidpublisher/v3/applications/com.somepackage.here/edits/ID_VERSION/tracks/beta?alt=json 返回“接收到无效的JSON有效负载。未知名称“ versionCodes” 在'track_config':找不到字段。“。详细信息:” [{'@type': 'type.googleapis.com/google.rpc.BadRequest'、'fieldViolations': [{'field':'track_config','description':'无效的JSON有效负载 收到。 “ track_config”处的未知名称“ versionCodes”:找不到 字段。'}]}]“>
我的代码如下:
track_response = service.edits().tracks().update(
editId=edit_id,
track=TRACK,
packageName=package_name,
body={u'versionCodes': [apk_response['versionCode']]}).execute()
我真的确定问题出在这里。
我一直在某些网站上寻求帮助,但似乎没有记录在案,我找到了一个相关的解决方案,但是找到了here中的Java库。
如果您能帮助我,我会很感激。
答案 0 :(得分:0)
我遇到了同样的问题,在阅读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()