Google我的业务API Python-构建错误 - 未知

发布于 2025-02-11 23:47:13 字数 1898 浏览 2 评论 0 原文

我正在尝试更新Google在Blask应用程序中的封面照片。以下是我实现同样的代码。

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版本:v1

我尝试将版本更改为 api_version to v4 和<代码> DiscoveryServiceurl V4 。但是错误仍然存​​在。

到目前为止已转介的文档:

,但似乎没有什么可用。请提出建议。

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:

But nothing seems to work. Suggestions Please.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

前事休说 2025-02-18 23:47:13

你快到了。

对于 api_version ,您需要将其设置为 v4 ;因为 MyBusiness 服务在V4上工作。

对于Discoveryurl,您需要以下以下将其传递:

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

You are almost there.

For API_VERSION, you need to set it to v4; because the mybusiness service is working on v4.

And for discoveryUrl, you need to pass it as following:

discoveryServiceUrl="https://developers.google.com/my-business/samples/mybusiness_google_rest_v4p9.json"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文