繁体   English   中英

Google My Business API Python - 构建错误 - UnknownApiNameOrVersion

[英]Google My Business API Python - Build Error - UnknownApiNameOrVersion

我正在尝试在 Flask App 中更新 Google My Business 的封面照片。 下面是我实现相同的代码。

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

这给出了一个错误: googleapiclient.errors.UnknownApiNameOrVersion: name: mybusiness version: v1

我尝试将版本更改为API_VERSIONv4discoveryServiceUrlv4 但错误仍然存​​在。

到目前为止参考的文档:

但似乎没有任何效果。 请提出建议。

你快到了。

对于API_VERSION ,您需要将其设置为v4 因为mybusiness服务正在开发 v4。

对于discoveryUrl,您需要按如下方式传递它:

discoveryServiceUrl="https://developers.google.com/my-business/samples/mybusiness_google_rest_v4p9.json"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM