python - Google Ads API v8 中不存在指定类型“google_ads_failure”
问题描述
我有两个问题:
我正在调用 G-Ads API 来批量删除广告(代码)
for error_detail in error_details:
# Retrieve an instance of the google_ads_failure class from the client
failure_message = gAdsServiceWrapper.client.get_type("google_ads_failure")
# Parse the string into a google_ads_failure message instance.
# To access class-only methods on the message we retrieve its type.
google_ads_failure = type(failure_message)
failure_object = google_ads_failure.deserialize(error_detail.value)
for error in failure_object.errors:
# Construct and print a string that details which element in
# the above ad_group_operations list failed (by index number)
# as well as the error message and error code.
print("A partial failure at index "
f"{error.location.field_path_elements[0].index} occurred "
f"\nError message: {error.message}\nError code: "
f"{error.error_code}")
index_array.append(error.location.field_path_elements[0].index)
error_array.append({"error_message": error.message, "error_code": error.error_code})
- 我收到部分错误
- 并且代码解析失败(取自官网)
我的终端显示:
发生部分故障。详情将在下面显示。
Traceback (most recent call last):
File "D:\projects\bowling\venv\lib\site-packages\google\ads\googleads\client.py", line 426, in get_type
message_class = getattr(type_classes, name)
File "D:\projects\bowling\venv\lib\site-packages\google\ads\googleads\v8\__init__.py", line 1753, in __getattr__
raise AttributeError(f"unknown type {name!r}.")
AttributeError: unknown type 'google_ads_failure'.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\projects\bowling\src\main.py", line 535, in <module>
main(args.top_id)
File "D:\projects\bowling\src\main.py", line 141, in main
removed_ads_count = remove_disapproved_ads_for_account(account)
File "D:\projects\bowling\src\main.py", line 206, in remove_disapproved_ads_for_account
remove_ads(ad_removal_operations, ads_to_remove_json, account_id)
File "D:\projects\bowling\src\main.py", line 300, in remove_ads
index_array, error_array = _print_results(response_chunk)
File "D:\projects\bowling\src\main.py", line 439, in _print_results
failure_message = gAdsServiceWrapper.client.get_type("google_ads_failure")
File "D:\projects\bowling\venv\lib\site-packages\google\ads\googleads\client.py", line 428, in get_type
raise ValueError(
ValueError: Specified type 'google_ads_failure' does not exist in Google Ads API v8
解决方案
failure_message = gAdsServiceWrapper.client.get_type("google_ads_failure")
我认为这应该是 - failure_message = gAdsServiceWrapper.client.get_type("GoogleAdsFailure")
推荐阅读
- java - JavaFX 记忆游戏(无法隐藏图块的值)
- spring-boot - “com.netflix.client.ClientException:负载均衡器没有可用于客户端的服务器:外汇服务”
- postgis - 在QGIS中点击地图可以在Postgis中输入地图点吗?
- python - min_max_scaler.fit_transform:ValueError:使用序列设置数组元素
- java - 为什么 maven-compiler-plugin 排除禁用
- rest - 如何在同一端口上启用 TLS 服务 gRPC 和 REST
- flutter - (颤振/飞镖)字符串换行获取错误:语法错误:未终止的字符串。:未定义的位置
- npm - 我可以对 peerDependencies 有一个后备吗?
- javascript - 正则表达式替换查询参数(++、+- 和 +)中的前导加号字符?
- vue.js - 有没有办法在 beforeRouteEnter 中显示 bootstrap-vue $toast 反馈?