【问题标题】:No ETag in response from Amazon Appstore亚马逊应用商店没有回应 ETag
【发布时间】:2020-04-07 12:55:43
【问题描述】:

作为我的团队从手动上传到自动上传过渡的一部分,我正在尝试在 Amazon Appsotre 中实施替换 apk 的流程。
我根据亚马逊为此流程发布的示例编写了代码。

'''

# Get the current list of APKs
get_apks_path = f"v1/applications/{app_id}/edits/{edit_id}/apks"
get_apks_url = '/'.join([BASE_URL, get_apks_path])
apks = requests.get(get_apks_url, headers=token)
apks_json = apks.json()
if 'Message' in apks_json:
    print(apks.content)
    sys.exit(1)
else:
    if apks_json.headers['ETag'] is None:
        print("No Etag found")
        sys.exit(1)
    else:
        etag = apks.headers['Etag']
    firstapk = apks_json[0]
    apk_id = firstapk['id']
    replace_apk_path = f"v1/applications/{app_id}/edits/{edit_id}/apks/{apk_id}/replace"
    # Open the apk file on your local machine
    local_apk = open(apk_location, 'rb').read()
    replace_apk_url = '/'.join([BASE_URL, replace_apk_path])
    all_headers = {
           'Content-Type': 'application/vnd.android.package-archive',
           'If-Match': etag
       }
    all_headers.update(token)
    replace_apk_response = requests.put(replace_apk_url,  data=local_apk, headers=all_headers)
    print(replace_apk_response.content)

'''

问题是,当我阅读 GET 请求的响应时,我看不到 ETag,这是完成流程所必需的。
我错过了什么吗?
ETag 说明及示例链接:
https://developer.amazon.com/docs/app-submission-api/flows.html#about-etags
https://developer.amazon.com/docs/app-submission-api/python-example.html

【问题讨论】:

    标签: python amazon-appstore


    【解决方案1】:

    我遇到了同样的问题。为了获取您要上传的 apk 的 eTag,您首先需要向 apk 端点发出 GET 请求。

    get_apk_path = '/v1/applications/%s/edits/%s/apks/%s' % (app_id, edit_id, androidApkId)
    get_apk_url = BASE_URL + get_apk_path
    apk_response = requests.get(get_apk_url, headers=auth_token_header)
    
    etagApk = apk_response.headers['Etag']
    print("Etag of the apk: " + etagApk)
    

    【讨论】:

      猜你喜欢
      • 2022-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-31
      • 1970-01-01
      • 2011-08-10
      • 2015-06-02
      • 1970-01-01
      相关资源
      最近更新 更多