Code: 

ad_group_ad_service = client.get_service("AdGroupAdService", version="v6")
ad_group_ad_operation = client.get_type("AdGroupAdOperation", version="v6")
resource_name = ad_group_ad_service.ad_group_ad_path(
  customer_id, ResourceName.format_composite(ad_group_id, ad_id)
)
ad_group_ad_operation.remove = resource_name
try:
  ad_group_ad_response = ad_group_ad_service.mutate_ad_group_ads(
    customer_id, [ad_group_ad_operation]
  )
except google.ads.google_ads.errors.GoogleAdsException as ex:
   log_proj.error(
    '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:
    log_proj.error('\tError with message "%s".' % error.message)
  if error.location:
    for field_path_element in error.location.field_path_elements:
      log_proj.error("\t\tOn field: %s" % field_path_element.field_name)
    sys.exit(1)

------------
Log:

Traceback (most recent call last):
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/publish/service/googleads/get_campaigns.py",
 
line 124, in modify_google_ad_detail
    ad_group_ad_response = ad_group_ad_service.mutate_ad_group_ads(
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/google/ads/google_ads/v6/services/ad_group_ad_service_client.py",
 
line 313, in mutate_ad_group_ads
    return self._inner_api_calls['mutate_ad_group_ads'](request, 
retry=retry, timeout=timeout, metadata=metadata)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/google/api_core/gapic_v1/method.py",
 
line 145, in __call__
    return wrapped_func(*args, **kwargs)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/google/api_core/retry.py",
 
line 281, in retry_wrapped_func
    return retry_target(
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/google/api_core/retry.py",
 
line 184, in retry_target
    return target()
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/google/api_core/timeout.py",
 
line 214, in func_with_timeout
    return func(*args, **kwargs)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/google/api_core/grpc_helpers.py",
 
line 57, in error_remapped_callable
    return callable_(*args, **kwargs)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/grpc/_interceptor.py",
 
line 216, in __call__
    response, ignored_call = self._with_call(request,
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/grpc/_interceptor.py",
 
line 257, in _with_call
    return call.result(), call
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/grpc/_interceptor.py",
 
line 126, in result
    raise self._exception
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/grpc/_interceptor.py",
 
line 241, in continuation
    response, call = self._thunk(new_method).with_call(
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/grpc/_interceptor.py",
 
line 266, in with_call
    return self._with_call(request,
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/grpc/_interceptor.py",
 
line 257, in _with_call
    return call.result(), call
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/grpc/_interceptor.py",
 
line 126, in result
    raise self._exception
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/grpc/_interceptor.py",
 
line 241, in continuation
    response, call = self._thunk(new_method).with_call(
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/grpc/_interceptor.py",
 
line 266, in with_call
    return self._with_call(request,
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/grpc/_interceptor.py",
 
line 254, in _with_call
    call = self._interceptor.intercept_unary_unary(continuation,
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/google/ads/google_ads/interceptors/exception_interceptor.py",
 
line 169, in intercept_unary_unary
    self._handle_grpc_failure(response)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/google/ads/google_ads/interceptors/exception_interceptor.py",
 
line 141, in _handle_grpc_failure
    raise self._get_error_from_response(response)
google.ads.google_ads.errors.GoogleAdsException: (<_InactiveRpcError of RPC 
that terminated with:
        status = StatusCode.INVALID_ARGUMENT
        details = "Request contains an invalid argument."
        debug_error_string = 
"{"created":"@1613765754.151575000","description":"Error received from peer 
ipv4:127.0.0.1:7890","file":"src/core/lib/surface/call.cc","file_line":1063,"grpc_message":"Request
 
contains an invalid argument.","grpc_status":3}"
>, <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.INVALID_ARGUMENT
        details = "Request contains an invalid argument."
        debug_error_string = 
"{"created":"@1613765754.151575000","description":"Error received from peer 
ipv4:127.0.0.1:7890","file":"src/core/lib/surface/call.cc","file_line":1063,"grpc_message":"Request
 
contains an invalid argument.","grpc_status":3}"
>, errors {
  error_code {
    operation_access_denied_error: OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE
  }
  message: "This operation is not permitted on this campaign type"
  trigger {
    string_value: ""
  }
  location {
    field_path_elements {
      field_name: "operations"
      index: 0
    }
    field_path_elements {
      field_name: "remove"
    }
  }
}
, 'x23hLPyacqx1Myc2XD6uCg')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/wsgiref/handlers.py",
 
line 137, in run
    self.result = application(self.environ, self.start_response)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/contrib/staticfiles/handlers.py",
 
line 76, in __call__
    return self.application(environ, start_response)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/core/handlers/wsgi.py",
 
line 133, in __call__
    response = self.get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/core/handlers/base.py",
 
line 128, in get_response
    response = self._middleware_chain(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/core/handlers/exception.py",
 
line 47, in inner
    response = get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/utils/deprecation.py",
 
line 114, in __call__
    response = response or self.get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/core/handlers/exception.py",
 
line 47, in inner
    response = get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/utils/deprecation.py",
 
line 114, in __call__
    response = response or self.get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/core/handlers/exception.py",
 
line 47, in inner
    response = get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/utils/deprecation.py",
 
line 114, in __call__
    response = response or self.get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/core/handlers/exception.py",
 
line 47, in inner
    response = get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/utils/deprecation.py",
 
line 114, in __call__
    response = response or self.get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/core/handlers/exception.py",
 
line 47, in inner
    response = get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/utils/deprecation.py",
 
line 114, in __call__
    response = response or self.get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/core/handlers/exception.py",
 
line 47, in inner
    response = get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/utils/deprecation.py",
 
line 114, in __call__
    response = response or self.get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/core/handlers/exception.py",
 
line 47, in inner
    response = get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/utils/deprecation.py",
 
line 114, in __call__
    response = response or self.get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/core/handlers/exception.py",
 
line 47, in inner
    response = get_response(request)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/venv-3.6/lib/python3.9/site-packages/django/core/handlers/base.py",
 
line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/publish/service/modify_ad.py",
 
line 237, in change_campaign
    modify_status(level, cam_id, new_status, type, ad_group_id)
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/publish/service/googleads/get_campaigns.py",
 
line 195, in modify_status
    modify_google_ad_detail(ad_group_id, id, type, value, 'biaoti1')
  File 
"/Users/zhumengqi/workspace/fancyguo/faxing/fancy_decision/publish/service/googleads/get_campaigns.py",
 
line 137, in modify_google_ad_detail
    sys.exit(1)
SystemExit: 1
ERROR   2021-02-20T04:15:54+0800        basehttp.py:157 
basehttp.log_message()  "POST /publish/campaign/change HTTP/1.1" 500 59
在2021年2月19日星期五 UTC+8 下午11:28:55<adsapiforumadvisor> 写道:

> Hello,
>
> Please see my replies to your questions below: 
>    
>    1. The remove operation 
>    
> <https://developers.google.com/google-ads/api/reference/rpc/v6/AdGroupAdOperation>
>  
>    is possible for AppAds. If you can send us the complete request and 
>    response logs associated with the operation permitted error, we can have a 
>    closer look. 
>    2. Editing existing AppAds is not possible using the Google Ads API. 
>    If this becomes supported, we will announce it on the Ads Developer 
>    blog 
>    <https://ads-developers.googleblog.com/search/label/google_ads_scripts>
>    . 
>
> Regards,
> Matt
> Google Ads API Team
>
> [image: Google Logo] 
> Matt 
> Google Ads API Team 
>   
>
>
>  
>
> ref:_00D1U1174p._5004Q2CSOPt: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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/0539c0fc-5a85-4594-9a4a-6842c5c5cff2n%40googlegroups.com.

Reply via email to