Python Client Library: Uploading Photos to Google Business Profile (Need Correct Service Name & Meth

Hello,

I am seeking assistance with the Google Business Profile API.

I am currently trying to develop a Python program (using the google-api-python-client library) to upload photos (as byte data) from a local directory to the media library of a Google Business Profile listing.

Objective: To programmatically upload local image files to the media library of a specified business listing on a regular basis using a Python script.

What I've Tried and the Issues Encountered:

  1. I have successfully implemented OAuth 2.0 authentication using the google-api-python-client library.
  2. I am encountering googleapiclient.errors.UnknownApiNameOrVersion errors when trying to build the API service object using the build() function, as I am unable to determine the correct service name and version.
    • Attempting build('mybusiness', 'v4', ...) results in an UnknownApiNameOrVersion error.
    • Attempting build('mybusiness', 'v1', ...) also results in an UnknownApiNameOrVersion error.
  3. When I check the enabled APIs in my GCP project library, I do not see a direct entry искусство "Google My Business API". Instead, the following related APIs are enabled:
    • My Business Business Information API (Service Name: mybusinessbusinessinformation.googleapis.com, Status: Enabled)
    • My Business Notifications API
    • My Business Lodging API
    • My Business Q&A API
    • My Business Place Actions API
    • My Business Account Management API
    • My Business Verifications API
    • Business Profile Performance API
  4. I was able to successfully build a service object using build('mybusinessbusinessinformation', 'v1', ...). However, I could not find the appropriate methods (e.g., locations().media().create(), locations_media().create(), etc.) on this service object to upload media bytes, leading to AttributeError.
  5. I have referred to the official documentation for uploading media from bytes, which outlines a 3-step process:
    • POST .../media:startUpload
    • POST bytes to an upload URL
    • POST .../media (with dataRef) I have attempted to implement this flow in Python, but the build() issue (point 2) prevents me from obtaining the correct service object to initiate these calls.

Questions:

  1. As of May 2025, when using the Python google-api-python-client library to upload local photos (as byte data) to the Google Business Profile media library, what are the correct service name and version hạt that should be specified in the build() function?
  2. Using the correct service name and version identified above, could you please provide a concrete Python code example for uploading photo bytes? Specifically, I am interested in the method chain for the 3-step flow described in the documentation (startUpload -> byte POST -> media.create with dataRef), or a simpler direct upload method if available. I am particularly interested in the correct method chain if using the mybusinessbusinessinformation v1 API.

Environment:

  • Libraries: google-api-python-client, google-auth-oauthlib, requests (if necessary for direct HTTP calls)
  • Python Version: 3.11
  • Desired Operation: Uploading photo bytes to the media library.

Thank you for your time and assistance. Any guidance you can provide would be greatly appreciated.

0 1 121
1 REPLY 1

Hi @YUKI310,

Welcome to Google Cloud Community!

According to this documentation, you should ensure that the Google My Business API (v4) is enabled in your GCP project, as the media upload functionality is part of this API, not the My Business Business Information API. The correct service name for the Google My Business API is 'mybusiness', and the version should be 'v4'. Then, just follow the 3-step upload process. This should help you upload photos to your Google Business Profile successfully.

Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.