Search code examples
pythonpython-3.xgoogle-my-business-api

Python Google My Business V1 Error - AttributeError: 'Resource' object has no attribute 'locations'


I am trying to get the listings under a Local Account in Google My Business through API.

CLIENT_SECRETS_FILE = "client_secret.json"
SCOPES = ["https://www.googleapis.com/auth/business.manage"]

API_SERVICE_NAME = "mybusiness"
API_VERSION = "v1"

service = googleapiclient.discovery.build(
        API_SERVICE_NAME,
        API_VERSION,
        credentials=credentials,
        discoveryServiceUrl="https://mybusinessaccountmanagement.googleapis.com/$discovery/rest?version=v1",
    )

response = (
    service.accounts()
    .locations()
    .lists(parent="accounts/113097808549740046769")
    .execute()
)

This is returning error: AttributeError: 'Resource' object has no attribute 'locations'

Please advise.


Solution

  • The accounts.locations.list method is part of the Business Information API, not the Account Management API.