Unable to create and attach shared keywords in Google Ads API python client

108 views
Skip to first unread message

Michael Xue

unread,
Jan 13, 2020, 4:08:16 PM1/13/20
to AdWords API and Google Ads API Forum

When running the example create_and_attach_shared_keyword_set.py with the latest Python client 4.1.1 release, I'm getting the following error. I've also posted the issue in the Github python client issue section, but I'm wondering if there are limitations on what types of campaigns I can apply the shared keyword set to? In my case, I was trying to attach the shared keywords to a video campaign. Is this also the case for shared negative placements set? The strange thing is that it use to work but now is broken.


Created shared criterion "customers/{obfuscated}/sharedCriteria/{obfuscated}~{obfuscated}".
Created shared criterion "customers/{obfuscated}/sharedCriteria/{obfuscated}~{obfuscated}".
Request made: ClientCustomerId: {obfuscated}, Host: googleads.googleapis.com:443, Method: /google.ads.googleads.v2.services.CampaignSharedSetService/MutateCampaignSharedSets, RequestId: None, IsFault: True, FaultMessage: None
Traceback (most recent call last):
  File "/Users/{obfuscated}/Projects/google-ads-python/examples/advanced_operations/create_and_attach_shared_keyword_set.py", line 130, in <module>
    main(google_ads_client, args.customer_id, args.campaign_id)
  File "/Users/{obfuscated}/Projects/google-ads-python/examples/advanced_operations/create_and_attach_shared_keyword_set.py", line 99, in main
    customer_id, [campaign_set_operation]).results[0].resource_name)
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/google/ads/google_ads/v2/services/campaign_shared_set_service_client.py", line 402, in mutate_campaign_shared_sets
    return self._inner_api_calls['mutate_campaign_shared_sets'](request, retry=retry, timeout=timeout, metadata=metadata)
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py", line 143, in __call__
    return wrapped_func(*args, **kwargs)
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/google/api_core/retry.py", line 286, in retry_wrapped_func
    on_error=on_error,
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/google/api_core/retry.py", line 184, in retry_target
    return target()
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/google/api_core/timeout.py", line 214, in func_with_timeout
    return func(*args, **kwargs)
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/grpc/_interceptor.py", line 222, in __call__
    compression=compression)
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/grpc/_interceptor.py", line 257, in _with_call
    return call.result(), call
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/grpc/_interceptor.py", line 126, in result
    raise self._exception
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/grpc/_interceptor.py", line 248, in continuation
    compression=new_compression)
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/grpc/_interceptor.py", line 272, in with_call
    compression=compression)
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/grpc/_interceptor.py", line 257, in _with_call
    return call.result(), call
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/grpc/_interceptor.py", line 126, in result
    raise self._exception
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/grpc/_interceptor.py", line 248, in continuation
    compression=new_compression)
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/grpc/_interceptor.py", line 272, in with_call
    compression=compression)
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/grpc/_interceptor.py", line 256, in _with_call
    continuation, client_call_details, request)
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/google/ads/google_ads/interceptors/exception_interceptor.py", line 139, in intercept_unary_unary
    self._handle_grpc_failure(response)
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/google/ads/google_ads/interceptors/exception_interceptor.py", line 105, in _handle_grpc_failure
    google_ads_failure = self._get_google_ads_failure(trailing_metadata)
  File "/Users/{obfuscated}/.local/share/virtualenvs/google-ads-python-ObS9Yvf7/lib/python3.7/site-packages/google/ads/google_ads/interceptors/exception_interceptor.py", line 68, in _get_google_ads_failure
    ga_failure = error_protos.errors_pb2.GoogleAdsFailure()
AttributeError: module 'google.ads.google_ads.v2.proto.errors' has no attribute 'errors_pb2

Google Ads API Forum Advisor Prod

unread,
Jan 13, 2020, 4:45:07 PM1/13/20
to micha...@openslate.com, adwor...@googlegroups.com

Hi Michael,

Thank you for reaching out. It looks like it’s a setup issue in which there could have been a problem with the way the client library was installed, in which it is not reading the attribute file ‘errors_pb2’ while the the attribute is being used in the script. In this case I would recommend you to re-download and install the latest version of our client library to remedy setup issues. For Google Ads Python, you can find the latest version here. Could you give that a try and let me know if you still run into issues with attaching the shared keyword set to your video campaign, as they should be able to have shared sets?

Thank you,
Bryan, Google Ads API Team



ref:_00D1U1174p._5001USwM6Y:ref

Michael Xue

unread,
Jan 13, 2020, 5:23:21 PM1/13/20
to AdWords API and Google Ads API Forum
Hi Bryan,

Thanks for getting back to me. I tried running the same file but with an older version (4.0.0) of the client and got this exception:

Request with ID "zHpKD9RV14iyrt3TsCd2Hg" failed with status "INVALID_ARGUMENT" and includes the following errors:
Request made: ClientCustomerId: 7887825568, Host: googleads.googleapis.com:443, Method: /google.ads.googleads.v2.services.CampaignSharedSetService/MutateCampaignSharedSets, RequestId: zHpKD9RV14iyrt3TsCd2Hg, IsFault: True, FaultMessage: The error code is not in this version.
Error with message "The error code is not in this version.".
On field: operations


I can confirm the same error when I make an API call using curl with https://googleads.googleapis.com/v2/customers/{obfuscated}/campaignSharedSets:mutate.
Here's the JSON body:
{
    "operations": [
        {
            "create": {
                "campaign": {
                    "value": "customers/{obfuscated}/campaigns/{obfuscated}"
                },
                "shared_set": {
                    "value": "customers/{obfuscated}/sharedSets/{obfuscated}"
                }
            }
        }
    ]
}

I get the following response

{
  "error": {
    "code"400,
    "message""Request contains an invalid argument.",
    "status""INVALID_ARGUMENT",
    "details": [
      {
        "errors": [
          {
            "errorCode": {
              "requestError""UNKNOWN"
            },
            "message""The error code is not in this version.",
            "trigger": {
              "int64Value""4"
            },
            "location": {
              "fieldPathElements": [
                {
                  "fieldName""operations",
                  "index""0"
                }
              ]
            }
          }
        ]
      }
    ]
  }
}

Any ideas on why this is happening?

Michael Xue

unread,
Jan 13, 2020, 5:49:38 PM1/13/20
to AdWords API and Google Ads API Forum
Just an update, I tried the API call https://googleads.googleapis.com/v2/customers/{obfuscated}/campaignSharedSets:mutate with a Display campaign this time and it worked. But I was able to apply a shared keyword set/shared negative placement set to a video campaigns before. Is this a bug or you guys no longer support shared sets for video campaigns?

Google Ads API Forum Advisor Prod

unread,
Jan 14, 2020, 3:49:32 PM1/14/20
to micha...@openslate.com, adwor...@googlegroups.com

Hi Michael,

Thank you for the information. I tried applying a shared keyword set to a test video campaign and I did not run into any issues. If you use an old version of our client libraries, you may encounter the “INVALID_ARGUMENT” issue. For your previous issue with “AttributeError”, I advise that you reinstall the client library and give the query another try using the "create_an_attach_shared_keyword_set.py" file. Could you let me know if the video campaign is still giving you issues?



Thank you,
Bryan, Google Ads API Team



ref:_00D1U1174p._5001USwM6Y:ref

Michael Xue

unread,
Jan 14, 2020, 4:19:21 PM1/14/20
to AdWords API and Google Ads API Forum
Reply all
Reply to author
Forward
0 new messages