Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the new update in AppStore Connect API break our applaud? #3

Open
canh-tran-20230331 opened this issue Aug 8, 2024 · 1 comment

Comments

@canh-tran-20230331
Copy link

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!

@reitowo
Copy link

reitowo commented Aug 11, 2024

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants