As part of the transition in my team from manual uploads to automatic uploads I'm trying to implement the flow of replacing apk in Amazon Appsotre.
I wrote the code based on the example that Amazon published for this flow.
'''
# 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)
'''
The problem is that when I'm reading the response for the GET request I don't see ETag, which is mandatory in order to complete flow.
Am I missing something?
Links for the explanation about the ETag and example:
https://developer.amazon.com/docs/app-submission-api/flows.html#about-etags
https://developer.amazon.com/docs/app-submission-api/python-example.html
I ran into the same issue. In order to get the eTag of the apk you want to upload you first need to do a GET request to the apk endpoint.