大量修改
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
如果您需要同時對不同類型的實體執行作業,或偏好對單一端點進行寫入,而不是為每個資源類型使用個別端點,則可以對所有支援的變動作業使用 GoogleAdsService.Mutate
端點。
修改作業
每個 MutateGoogleAdsRequest
都會接受重複的 MutateOperation
,每個 MutateOperation
可包含一個資源類型的單一作業。如要在單一 GoogleAdsService.Mutate
呼叫中建立一個廣告活動和一個廣告群組,您需要建立兩個 MutateOperation
實體 (一個用於 CampaignOperation
,另一個用於 AdGroupOperation
),然後將兩者傳遞至 GoogleAdsService
。
小茹
mutate_operation1 = client.operation(:Mutate)
mutate_operation2 = client.operation(:Mutate)
campaign_operation = client.operation(:Campaign)
ad_group_operation = client.operation(:AdGroup)
# Do some setup here to get campaign_operation and ad_group_operation into the
# state you would want them for a regular mutate call to their respective
# services.
mutate_operation1.campaign_operation = campaign_operation
mutate_operation2.ad_group_operation = ad_group_operation
google_ads_service.mutate(customer_id, [mutate_operation1, mutate_operation2])
與其他服務一樣,這個端點支援部分失敗和僅驗證。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-27 (世界標準時間)。
[null,null,["上次更新時間:2025-08-27 (世界標準時間)。"],[[["\u003cp\u003eUse the \u003ccode\u003eGoogleAdsService.Mutate\u003c/code\u003e endpoint to operate on different entity types or prefer a single endpoint.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eMutateGoogleAdsRequest\u003c/code\u003e accepts multiple \u003ccode\u003eMutateOperation\u003c/code\u003e entities, each handling a single operation for one resource type.\u003c/p\u003e\n"],["\u003cp\u003eConstruct separate \u003ccode\u003eMutateOperation\u003c/code\u003e objects for each desired operation, like creating a campaign and an ad group, and pass them to \u003ccode\u003eGoogleAdsService\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThis endpoint supports partial failure handling and validate-only requests, similar to other Google Ads API services.\u003c/p\u003e\n"]]],[],null,["# Bulk Mutates\n\nIf you need to operate on different types of entities at the same time or\nprefer to write against a single endpoint rather than using a separate endpoint\nper resource type, then you can use the\n[`GoogleAdsService.Mutate`](/google-ads/api/reference/rpc/v21/GoogleAdsService/Mutate)\nendpoint for all supported mutate operations.\n| **Note:** You can see the full list of supported operations on the reference page for [`MutateOperation`](/google-ads/api/reference/rpc/v21/MutateOperation).\n\nMutate operations\n-----------------\n\nEach [`MutateGoogleAdsRequest`](/google-ads/api/reference/rpc/v21/MutateGoogleAdsRequest)\naccepts a repeated [`MutateOperation`](/google-ads/api/reference/rpc/v21/MutateOperation), each of\nwhich can include a single operation for one resource type. To create one\ncampaign and one ad group in a single\n[`GoogleAdsService.Mutate`](/google-ads/api/reference/rpc/v21/GoogleAdsService/Mutate) call,\nyou would need to create two [`MutateOperation`](/google-ads/api/reference/rpc/v21/MutateOperation)\nentities (one for the [`CampaignOperation`](/google-ads/api/reference/rpc/v21/CampaignOperation),\nthe other for the [`AdGroupOperation`](/google-ads/api/reference/rpc/v21/AdGroupOperation)),\nand then pass both to\n[`GoogleAdsService`](/google-ads/api/reference/rpc/v21/GoogleAdsService). \n\n### Ruby\n\n mutate_operation1 = client.operation(:Mutate)\n mutate_operation2 = client.operation(:Mutate)\n\n campaign_operation = client.operation(:Campaign)\n ad_group_operation = client.operation(:AdGroup)\n\n # Do some setup here to get campaign_operation and ad_group_operation into the\n # state you would want them for a regular mutate call to their respective\n # services.\n\n mutate_operation1.campaign_operation = campaign_operation\n mutate_operation2.ad_group_operation = ad_group_operation\n\n google_ads_service.mutate(customer_id, [mutate_operation1, mutate_operation2])\n\nLike other services, this endpoint supports\n[partial failure](/google-ads/api/docs/best-practices/partial-failures) and\nvalidate-only."]]