The code below loops over a list `response` containing tuples where the 
first element (`c[0]` in the snippet) is a campaign ID:

for c in response:
   campaign_operation = client.get_type('CampaignOperation')
   operation = campaign_operation.update
   operation.resource_name = campaign_service.campaign_path(google_id, c[0])
   operation.status = client.enums.CampaignStatusEnum.PAUSED
   client.copy_from(campaign_operation.update_mask, 
protobuf_helpers.field_mask(None, operation._pb))
   operations.append(operation)

campaign_response = campaign_service.mutate_campaigns(customer_id=google_id, 
operations=operations)

The last line throws the following exception:

Traceback (most recent call last):
  File "F:/.../campaign_pauser.py", line 162, in <module>
    campaign_response = 
campaign_service.mutate_campaigns(customer_id=google_id, 
operations=operations)
  File 
"F:\...\venv\lib\site-packages\google\ads\googleads\v8\services\services\campaign_service\client.py",
 
line 610, in mutate_campaigns
    request.operations = operations
  File "F:\...\venv\lib\site-packages\proto\message.py", line 641, in 
__setattr__
    self._pb.MergeFrom(self._meta.pb(**{key: pb_value}))
TypeError: Parameter to MergeFrom() must be instance of same class: 
expected google.ads.googleads.v8.services.CampaignOperation got Campaign.

The code I'm using is essentially from the documentation here:

https://github.com/googleads/google-ads-python/blob/master/examples/basic_operations/update_campaign.py

Cannot understand why there's a type mismatch happening. Any help 
appreciated.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/fda1fe80-41ea-40aa-ad2c-25b0bdd90f1cn%40googlegroups.com.
  • &q... Bob Rzadzki
    • ... 'Google Ads API Forum Advisor' via AdWords API and Google Ads API Forum
      • ... Bob Rzadzki

Reply via email to