def remove_disapproved_ads_for_account(account):
"""Remove all disapproved ads for a given customer id"""
query = f"""
SELECT
ad_group_ad.ad.type,
ad_group_ad.ad.text_ad.headline,
ad_group_ad.ad.text_ad.description1,
ad_group_ad.ad.text_ad.description2,
ad_group_ad.ad.expanded_text_ad.headline_part1,
ad_group_ad.ad.expanded_text_ad.headline_part2,
ad_group_ad.ad.expanded_text_ad.headline_part3,
ad_group_ad.ad.responsive_search_ad.headlines,
ad_group_ad.ad.responsive_search_ad.descriptions,
ad_group_ad.ad.responsive_search_ad.path1,
ad_group_ad.ad.responsive_search_ad.path2,
ad_group_ad.ad.type,
ad_group_ad.ad_group,
ad_group_ad.policy_summary.approval_status,
ad_group_ad.policy_summary.policy_topic_entries
FROM ad_group_ad
WHERE
ad_group_ad.policy_summary.approval_status = DISAPPROVED
AND ad_group_ad.status != REMOVED """
customer_id = account["id"]
rows = serviceWrapper.get_rows(customer_id, query)
disapproved_ads_count = 0
print(f"\nProcessing Account id: {customer_id} ")
We get an internal error. See client's logs below.
Request made: ClientCustomerId: 831*** Host:
googleads.googleapis.com, Method: /google.ads.googleads.v8.services.GoogleAdsService/Search, RequestId: rCdBckVYrIbzmHQ0FsYbpw, IsFault: True, FaultMessage: Internal error encountered.
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 66, in error_remapped_callable
return callable_(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/grpc/_interceptor.py", line 216, in __call__
response, ignored_call = self._with_call(request,
File "/usr/local/lib/python3.8/site-packages/grpc/_interceptor.py", line 257, in _with_call
return call.result(), call
File "/usr/local/lib/python3.8/site-packages/grpc/_channel.py", line 343, in result
raise self
File "/usr/local/lib/python3.8/site-packages/grpc/_interceptor.py", line 241, in continuation
response, call = self._thunk(new_method).with_call(
File "/usr/local/lib/python3.8/site-packages/grpc/_interceptor.py", line 266, in with_call
return self._with_call(request,
File "/usr/local/lib/python3.8/site-packages/grpc/_interceptor.py", line 257, in _with_call
return call.result(), call
File "/usr/local/lib/python3.8/site-packages/grpc/_channel.py", line 343, in result
raise self
File "/usr/local/lib/python3.8/site-packages/grpc/_interceptor.py", line 241, in continuation
response, call = self._thunk(new_method).with_call(
File "/usr/local/lib/python3.8/site-packages/grpc/_interceptor.py", line 266, in with_call
return self._with_call(request,
File "/usr/local/lib/python3.8/site-packages/grpc/_interceptor.py", line 254, in _with_call
call = self._interceptor.intercept_unary_unary(continuation,
File "/usr/local/lib/python3.8/site-packages/google/ads/googleads/interceptors/exception_interceptor.py", line 99, in intercept_unary_unary
self._handle_grpc_failure(response)
File "/usr/local/lib/python3.8/site-packages/google/ads/googleads/interceptors/exception_interceptor.py", line 71, in _handle_grpc_failure
raise self._get_error_from_response(response)
File "/usr/local/lib/python3.8/site-packages/grpc/_interceptor.py", line 241, in continuation
response, call = self._thunk(new_method).with_call(
File "/usr/local/lib/python3.8/site-packages/grpc/_channel.py", line 957, in with_call
return _end_unary_response_blocking(state, call, True, None)
File "/usr/local/lib/python3.8/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INTERNAL
details = "Internal error encountered."
debug_error_string = "{"created":"@163****2.51*****","description":"Error received from peer ipv4:
142.250.184.234:443","file":"src/core/lib/surface/call.cc","file_line":1070,"grpc_message":"Internal error encountered.","grpc_status":13}"
>