I am trying to Update Cover Photo of Google My Business in Flask App. Below is my code to achieve the same.
SCOPES = ["https://www.googleapis.com/auth/business.manage"]
API_SERVICE_NAME = "mybusiness"
API_VERSION = "v1"
API_KEY = "api-key-here"
CLIENT_SECRETS_FILE = "client_secret.json"
SCOPES = ["https://www.googleapis.com/auth/business.manage"]
gmb_app_verify_business_test.credentials = google.oauth2.credentials.Credentials(
**flask.session["credentials"])
flask.session["credentials"] = modules.credentials_to_dict(
gmb_app_verify_business_test.credentials)
service = googleapiclient.discovery.build(
API_SERVICE_NAME,
API_VERSION,
credentials=credentials,
developerKey=API_KEY,
discoveryServiceUrl="https://mybusiness.googleapis.com/$discovery/rest?version=v1",
)
cover_update_status = (
service.accounts()
.locations()
.media()
.create(
parent='accounts/xxxxxxxxxxxx/locations/xxxxxxxxxxxxxxxxxxxxxx',
body={
"name": "IFB Point Cover",
"mediaFormat": "PHOTO",
"locationAssociation": {
"category": "COVER",
},
"sourceUrl": "https://www.ifbappliances.com/media/ifb/ifb-point-cover.png",
},
)
.execute()
)
This is giving an error: googleapiclient.errors.UnknownApiNameOrVersion: name: mybusiness version: v1
I tried changing the version to API_VERSION
to v4
and discoveryServiceUrl
to v4
. But the error persists.
Documentation Referred so far:
- https://developers.google.com/my-business/content/upload-photos
- https://developers.google.com/my-business/reference/rest/v4/accounts.locations.media/create
But nothing seems to work. Suggestions Please.