Hello,

When I was setting *parentalStatus* of *AdGroupCriterion*, I encountered an 
error `*OPERATION_NOT_PERMITTED_FOR_CONTEXT*`


   - *Complete Error messages are as follows:*


```























*debug_error_string = "UNKNOWN:Error received from peer 
ipv4:142.251.42.234:443 {created_time:"2024-01-22T16:43:42.946377+08:00", 
grpc_status:3, grpc_message:"Request contains an invalid argument."}">, 
errors {  error_code {    context_error: 
OPERATION_NOT_PERMITTED_FOR_CONTEXT  }  message: "The operation is not 
allowed for the given context."  trigger {    string_value: 
"SEARCH(SEARCH_STANDARD)"  }  location {    field_path_elements {      
field_name: "operations"      index: 0    }    field_path_elements {      
field_name: "create"    }    field_path_elements {      field_name: 
"parental_status"    }  }}request_id: "FzSWqMhAFGEUOZiZiRc0VA", 
'FzSWqMhAFGEUOZiZiRc0VA')*
```


   - *My code was below:*

```
def main(client, customer_id, ad_group_id):
    ad_group_service = client.get_service("AdGroupService")
    ad_group_criterion_service = 
client.get_service("AdGroupCriterionService")
    ad_group_resource_name = ad_group_service.ad_group_path(customer_id, 
ad_group_id)

    # Exclude Parent
    parent_operation = client.get_type("AdGroupCriterionOperation")
    parent_criterion = parent_operation.create
    parent_criterion.ad_group = ad_group_resource_name
    parent_criterion.negative = True
    parent_criterion.parental_status.type_ = 
client.enums.ParentalStatusTypeEnum.PARENT

    ad_group_criterion_response = 
ad_group_criterion_service.mutate_ad_group_criteria(
        customer_id=customer_id,
        operations=[
            parent_operation
        ],
    )

    for result in ad_group_criterion_response.results:
        print(f"Created criterion {result.resource_name}.")


if __name__ == "__main__":
    client = get_client()
    CUSTOMER_ID = "5692452448"
    ad_group_id = "163236537532"
    main(client, CUSTOMER_ID, ad_group_id)
```

I had successfully modified criterion with income_range, gender, and age, 
but `parentalStatus` was not the case. Please assist with how to correct 
the error, thanks in advance.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 
"Google Ads API and AdWords 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/61b0f029-8972-429b-b73a-2371e6db4817n%40googlegroups.com.
  • Ca... Shawn Hsiao
    • ... Shawn Hsiao
      • ... Shawn Hsiao
        • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum

Reply via email to