I have a python example and that worked for me to pause the placement.
+++++++++++++++++++
def pause_placement (client, customer_id, ad_group_id, criterion_id):
agc_service = client.get_service("AdGroupCriterionService", version="v6")
ad_group_criterion_operation = client.get_type(
"AdGroupCriterionOperation", version="v6"
)
ad_group_criterion = ad_group_criterion_operation.update
ad_group_criterion.resource_name = agc_service.ad_group_criteria_path(
customer_id, ResourceName.format_composite(ad_group_id, criterion_id)
)
ad_group_criterion.status = client.get_type(
"AdGroupCriterionStatusEnum", version="v6"
).PAUSED
fm = protobuf_helpers.field_mask(None, ad_group_criterion)
ad_group_criterion_operation.update_mask.CopyFrom(fm)
try:
agc_response = agc_service.mutate_ad_group_criteria(
customer_id, [ad_group_criterion_operation]
)
except google.ads.google_ads.errors.GoogleAdsException as ex:
print(
'Request with ID "%s" failed with status "%s" and includes the '
"following errors:" % (ex.request_id, ex.error.code().name)
)
for error in ex.failure.errors:
print('\tError with message "%s".' % error.message)
if error.location:
for field_path_element in error.location.field_path_elements:
print("\t\tOn field: %s" % field_path_element.field_name)
sys.exit(1)
print("Updated placement status %s." %
agc_response.results[0].resource_name)
On Thursday, March 4, 2021 at 10:30:53 PM UTC+5 Google Ads API Explorer
wrote:
> @anthony,
>
> I did this but not able to pause the placements
>
> $adGroupCriterion = new AdGroupCriterion([
> 'resource_name' => ResourceNames::forAdGroupCriterion(
> $customerId,
> $adGroupId,
> $placementcriterionId
> ),
> 'status' => AdGroupCriterionStatus::PAUSED
> ]);
>
>
>
> $adGroupCriterionOperation = new AdGroupCriterionOperation();
> $adGroupCriterionOperation->setUpdate($adGroupCriterion);
>
>
> $adGroupCriterionOperation->setUpdateMask(FieldMasks::allSetFieldsOf($adGroupCriterion));
>
>
> // Issues a mutate request to update the ad group criterion.
>
> $adGroupCriterionServiceClient =
> $googleAdsClient->getAdGroupCriterionServiceClient();
>
> $response =
> $adGroupCriterionServiceClient->mutateAdGroupCriteria(
> $customerId,
> [$adGroupCriterionOperation]
> );
>
>
> On Thursday, March 4, 2021 at 10:01:52 PM UTC+5:30 Google Ads API Explorer
> wrote:
>
>> Can I pause placement using CampaignCriterion or AdGroupCriterion service
>> ?
>>
>> On Thursday, March 4, 2021 at 9:22:53 PM UTC+5:30 adsapiforumadvisor
>> wrote:
>>
>>> Hello,
>>>
>>> Unfortunately, we don't have an example on how to pause placements.
>>> However, you can use this example
>>> <https://developers.google.com/google-ads/api/docs/samples/update-keyword#python>
>>>
>>> as a reference. This example shows how to enable a keyword using
>>> AdGroupCriterionService. You will need to modify it to use PAUSED and the
>>> Id of your placements.
>>>
>>> Cheers,
>>> Anthony
>>>
>>> [image: Google Logo]
>>> Anthony
>>> Google Ads API Team
>>>
>>>
>>> ref:_00D1U1174p._5004Q2DKpxV:ref
>>>
>>
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/10c821a5-ac58-4fa1-8c85-2cebcfe27751n%40googlegroups.com.