applaud
applaud copied to clipboard
Is the new update in AppStore Connect API break our applaud?
First of all, thank you for this great library. This has been working for over a year for my application. But after August 1st, it stopped working.
After debugging, I believe the connection.builds() response structure has changed, and the current code is no longer valid.
BuildsResponse expected dict not Response (type=type_error)
This is our code:
#!/usr/bin/python3
import argparse
import os
from applaud.connection import Connection
from applaud.endpoints import BuildEndpoint
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('--appid', dest='app_id', type=str)
parser.add_argument('--keyid', dest='key_id', type=str)
parser.add_argument('--issuerid', dest='issuer_id', type=str)
parser.add_argument('--key', dest='key', type=str)
parser.add_argument('--output', dest='output', type=str)
args = parser.parse_args()
connection = Connection(args.issuer_id, args.key_id, args.key)
r = connection.builds().filter(
app=args.app_id
).include(
[BuildEndpoint.Include.BUILD_BUNDLES, BuildEndpoint.Include.APP_STORE_VERSION] # type: ignore
).limit(number=20).get()
for build in r.data:
try:
version = connection.build(build.id).app_store_version(
).get().data.attributes.version_string # type: ignore
build_bundle_id = build.relationships.build_bundles.data[0].id # type: ignore
size_info = connection.build_bundle(build_bundle_id).build_bundle_file_sizes().get()
file_path = args.output + '/' + version + '.json'
if os.path.exists(file_path):
exit(0)
with open(file_path, 'w') as out:
out.write(size_info.json())
print("Version: {0}, Data saved. Build Bundle ID: {1}".format(version, build_bundle_id))
except:
pass
Could you please help us identify if there has been any change in the response format for connection.builds() and suggest how we can update our code accordingly? Any help would be greatly appreciated!
Seems apple are setting application/vnd.api+json in Content-Type which this lib didn't handle yet.
Fix:
def __parse_response(self, response: requests.Response) -> Any:
content_type = response.headers['Content-Type']
if content_type == 'application/json' or content_type == 'application/vnd.api+json':
json = response.json()