0

I'm trying to list my builds that I have uploaded to Firebase App Distribution with the help of the google-api-python-client however I always get a HTTP status code 400.

I have created a service-account.json with full owner rights (for testing)
I have copied my project_id from Firebase Console.
I have copied my app_id from Firebase Console.

My Python script:

import os
from google.oauth2 import service_account
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError

script_dir = os.path.dirname(os.path.abspath(__file__))
service_account_file = os.path.join(script_dir, 'service-account.json')
credentials = service_account.Credentials.from_service_account_file(service_account_file)

project_id = credentials.project_id
app_id = "1:310501947997:android:4f5183af1eddc4004eabb4"

service = build('firebaseappdistribution', 'v1', credentials=credentials)

try:
    parent = f"projects/{project_id}/apps/{app_id}"
    app_releases = service.projects().apps().releases().list(parent=parent).execute()
    print(app_releases)
except HttpError as e:
    print('Error response status code : {0}, reason : {1}'.format(e.status_code, e.error_details))

Error response status code : 400, reason : Request contains an invalid argument.

Does somebody have any pointers on what argument is invalid which is causing the HTTP 400?

2
  • 1
    I think the problem is with the parent. You are using the Project ID but the documentation specifies Project Number: googleapis.github.io/google-api-python-client/docs/dyn/… Commented Dec 21, 2023 at 21:56
  • You are correct! Please post this as an answer. I want to reward you with some internet points. Commented Dec 22, 2023 at 8:34

1 Answer 1

1

Your code is using the Project ID. The API requires specifying the Project Number.

parent: string, Required. The name of the app resource, which is the parent of the release resources. Format: projects/{project_number}/apps/{app_id} (required)

Refer to this documentation for more details on the required parameters:

projects().apps().releases().list()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.