OPERATION_NOT_PERMITTED_FOR_CONTEXT for demographic targeting

100 views
Skip to first unread message

Lakshya Garg

unread,
Sep 27, 2021, 1:48:16 AM9/27/21
to AdWords API and Google Ads API Forum
Hi ,

I am having test account, and i am trying to create demographic targeting. I tried creating at campaign as well as ad level. but getting the exception: OPERATION_NOT_PERMITTED_FOR_CONTEXT..

Can you please help with this?

Google Ads API Forum Advisor

unread,
Sep 27, 2021, 3:45:30 AM9/27/21
to lakshy...@gmail.com, adwor...@googlegroups.com
Hi Lakshya,

Thank you for posting your concern.

To investigate the issue that you experienced, could you provide the complete request and response logs with request ID generated on your end where we can see the error?

If you haven't enabled the logging of the API transactions for the specific client library that you are using, then please refer to the specific guide below:
You can provide it via Reply privately to author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.

Regards,
Google Logo
Ernie John Blanca Tacata
Google Ads API Team
 


ref:_00D1U1174p._5004Q2OUL1d:ref

Lakshya Garg

unread,
Sep 27, 2021, 9:39:11 AM9/27/21
to AdWords API and Google Ads API Forum
Hi,

I am trying to add demographic for local campaign.

options[:customer_id] = '1642674633'
options[:ad_group_id] = '133212439888'

Please find the below logs:

request_id:  8orcWK_fFAnfvMeqTNet0g

WARN -- : CID: 1642674633, Host: googleads.googleapis.com:443, Method: /google.ads.googleads.v8.services.AdGroupCriterionService/MutateAdGroupCriteria, IsFault: yes, Request ID: 8orcWK_fFAnfvMeqTNet0g
Error with message: The operation is not allowed for the given context.
        On field: operations
        On field: create
        On field: gender
        Type: context_error
        Code: OPERATION_NOT_PERMITTED_FOR_CONTEXT
Error with message: The operation is not allowed for the given context.
        On field: operations
        On field: create
        On field: age_range
        Type: context_error
        Code: OPERATION_NOT_PERMITTED_FOR_CONTEXT
Traceback (most recent call last):
        13: from add_demographic_criteria.rb:77:in `<main>'
        12: from add_demographic_criteria.rb:29:in `add_demographic_targeting_criteria'
        11: from /Users/synup/.rvm/gems/ruby-2.5.1/gems/google-ads-googleads-14.0.0/lib/google/ads/google_ads/service_wrapper.rb:50:in `method_missing'
        10: from /Users/synup/.rvm/gems/ruby-2.5.1/gems/google-ads-googleads-14.0.0/lib/google/ads/google_ads/service_wrapper.rb:50:in `public_send'
         9: from /Users/synup/.rvm/gems/ruby-2.5.1/gems/google-ads-googleads-14.0.0/lib/google/ads/google_ads/v8/services/ad_group_criterion_service/client.rb:333:in `mutate_ad_group_criteria'
         8: from /Users/synup/.rvm/gems/ruby-2.5.1/gems/gapic-common-0.6.0/lib/gapic/grpc/service_stub.rb:156:in `call_rpc'
         7: from /Users/synup/.rvm/gems/ruby-2.5.1/gems/gapic-common-0.6.0/lib/gapic/grpc/service_stub/rpc_call.rb:121:in `call'
         6: from /Users/synup/.rvm/gems/ruby-2.5.1/gems/grpc-1.40.0-universal-darwin/src/ruby/lib/grpc/generic/client_stub.rb:173:in `block in request_response'
         5: from /Users/synup/.rvm/gems/ruby-2.5.1/gems/grpc-1.40.0-universal-darwin/src/ruby/lib/grpc/generic/interceptors.rb:175:in `intercept!'
         4: from /Users/synup/.rvm/gems/ruby-2.5.1/gems/google-ads-googleads-14.0.0/lib/google/ads/google_ads/interceptors/logging_interceptor.rb:53:in `request_response'
         3: from /Users/synup/.rvm/gems/ruby-2.5.1/gems/grpc-1.40.0-universal-darwin/src/ruby/lib/grpc/generic/interceptors.rb:177:in `block in intercept!'
         2: from /Users/synup/.rvm/gems/ruby-2.5.1/gems/grpc-1.40.0-universal-darwin/src/ruby/lib/grpc/generic/interceptors.rb:175:in `intercept!'
         1: from /Users/synup/.rvm/gems/ruby-2.5.1/gems/google-ads-googleads-14.0.0/lib/google/ads/google_ads/interceptors/error_interceptor.rb:63:in `request_response'
/Users/synup/.rvm/gems/ruby-2.5.1/gems/google-ads-googleads-14.0.0/lib/google/ads/google_ads/interceptors/error_interceptor.rb:67:in `rescue in request_response': Google::Ads::GoogleAds::Errors::GoogleAdsError (Google::Ads::GoogleAds::Errors::GoogleAdsError)

Google Ads API Forum Advisor

unread,
Sep 29, 2021, 2:06:05 AM9/29/21
to lakshy...@gmail.com, adwor...@googlegroups.com
Hi Lakshya,

Thank you for the trace that you provided. However, these do not appear to be the complete request and response logs with request ID that my colleague Ernie earlier requested.

That said, and since it appears that you are using Ruby, you can first enable logging by referring to this guide. Once enabled, you may retry your request and provide to our team the generated logs as these would greatly help us in troubleshooting the API error you are encountering.

Furthermore, I would highly recommend that you send the requested information via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.

Best regards,

Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


ref:_00D1U1174p._5004Q2OUL1d:ref
Reply all
Reply to author
Forward
0 new messages