Google.Ads.GoogleAds.E​​xamples返回的截止日期已超过

时间:2019-03-26 02:25:18

标签: python google-ads-api

我正在尝试运行第一个示例:通过python sdk(广告api,不是adwords)获取广告系列。 我收到一个错误,没有描述如何解决该问题:google.api_core.exceptions.DeadlineExceeded:超过504个截止日期

"""This example illustrates how to get all campaigns.

To add campaigns, run add_campaigns.py.
"""

from __future__ import absolute_import

import argparse
import six
import sys

import google.ads.google_ads.client


_DEFAULT_PAGE_SIZE = 10


def main(client, customer_id, page_size):
    ga_service = client.get_service('GoogleAdsService', version='v1')

    query = ('SELECT campaign.id, campaign.name FROM campaign '
             'ORDER BY campaign.id')

    results = ga_service.search(customer_id, query=query, page_size=page_size)

    try:
        for row in results:
            print('Campaign with ID %d and name "%s" was found.'
                  % (row.campaign.id.value, row.campaign.name.value))
    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)


if __name__ == '__main__':
    google_ads_client = (google.ads.google_ads.client.GoogleAdsClient
                         .load_from_storage("google-ads.yaml"))
    main(google_ads_client, "customer_id", _DEFAULT_PAGE_SIZE)

并收到错误:

Traceback (most recent call last):
  File "c:/PythonProjects/google_ads_api_test/google-ads-python-master/google-ads-python-master/examples/basic_operations/get_campaigns.py", line 68, in <module>
    main(google_ads_client, "customer_id", _DEFAULT_PAGE_SIZE)
  File "c:/PythonProjects/google_ads_api_test/google-ads-python-master/google-ads-python-master/examples/basic_operations/get_campaigns.py", line 40, in main
    for row in results:
  File "C:\Anaconda3\lib\site-packages\google\api_core\page_iterator.py", line 204, in _items_iter
    for page in self._page_iter(increment=False):
  File "C:\Anaconda3\lib\site-packages\google\api_core\page_iterator.py", line 235, in _page_iter
    page = self._next_page()
  File "C:\Anaconda3\lib\site-packages\google\api_core\page_iterator.py", line 526, in _next_page
    response = self._method(self._request)
  File "C:\Anaconda3\lib\site-packages\google\api_core\gapic_v1\method.py", line 143, in __call__
    return wrapped_func(*args, **kwargs)
  File "C:\Anaconda3\lib\site-packages\google\api_core\retry.py", line 270, in retry_wrapped_func
    on_error=on_error,
  File "C:\Anaconda3\lib\site-packages\google\api_core\retry.py", line 179, in retry_target
    return target()
  File "C:\Anaconda3\lib\site-packages\google\api_core\timeout.py", line 214, in func_with_timeout
    return func(*args, **kwargs)
  File "C:\Anaconda3\lib\site-packages\google\api_core\grpc_helpers.py", line 59, in error_remapped_callable
    six.raise_from(exceptions.from_grpc_error(exc), exc)
  File "<string>", line 3, in raise_from
google.api_core.exceptions.DeadlineExceeded: 504 Deadline Exceeded

通话有问题吗?

1 个答案:

答案 0 :(得分:0)

我相信您只需要增加配置中的超时值即可。