過去数年間、Google AdWords API を使用していくつかの Google AdWords 操作を管理していましたが、新しいバージョンに移行した後、1 つのことを除いて、古いバージョンで行っていたことをすべて再現しました。特定の広告グループ、これは古いバージョンがどのように見えるかです:
from googleads import adwords
def remove_label_adgroups(ad_group_id):
# Initialize appropriate service.
client = adwords.AdWordsClient.LoadFromStorage("googleads.yaml")
campaign_service = client.GetService('AdGroupService', version='v201809')
operations = [
{ 'operator': 'REMOVE',
'operand': {
'adGroupId': ad_group_id,
'labelId': 'xxxx',
} } ]
campaign_service.mutateLabel(operations)
remove_label_adgroups(ad_group_id)
これは動作しない新しいバージョンです:
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
def rmove(ad_group_id):
client=GoogleAdsClient.load_from_storage("./google-ads.yaml",version="v8")
# Get an instance of CampaignLabelService client.
customer_id="xxx"
label_id="xxx"
ad_group_ad_service = client.get_service("AdGroupLabelOperation")
ad_group_ad_operation = client.get_type("AdGroupAdOperation")
resource_name = ad_group_ad_service.ad_group_ad_path(customer_id, ad_group_id,label_id)
ad_group_ad_operation.remove = resource_name
ad_group_ad_service.mutate_ad_group_ads(customer_id=customer_id, operations=[ad_group_ad_operation])
rmove("xxxx")
どんな助けにも感謝します