Hi,

It looks like you just have a minor typo in your code. The second 
*Predicate* is named *predicateAdGroup*, but you set the attributes of the 
*first* *Predicate* named *predicate* in the second section.

      Predicate predicateAdGroup = new Predicate();
      predicate.field = "AdGroupId";
      predicate.@operator = PredicateOperator.IN;
      predicate.values = new string[] { adGroup.id.ToString() };

If you change that section of code to the following, then your example 
should work as expected.

      Predicate predicateAdGroup = new Predicate();
      predicateAdGroup.field = "AdGroupId";
      predicateAdGroup.@operator = PredicateOperator.IN;
      predicateAdGroup.values = new string[] { adGroup.id.ToString() };

Thanks,
Josh, AdWords API Team

On Friday, May 8, 2015 at 4:52:06 PM UTC-4, Cumhur YALÇIN wrote:
>
>
> Hello people,
>
> I'm just struggling to retrieve Keywords which belongs to an AdGroup 
> inside a campaign.
>
> Here we can see the hierarchy of the objects.
>
> https://support.google.com/adwords/answer/2475865
>
> What I am doing to retrieve is something like this:
>
>       Selector selectorKeyword = new Selector();
>       selectorKeyword.fields = new string[] { "Id", "AdGroupId", 
> "KeywordText" };
>
>       // Select only keywords.
>       predicate = new Predicate();
>       predicate.field = "CriteriaType";
>       predicate.@operator = PredicateOperator.EQUALS;
>       predicate.values = new string[] { "KEYWORD" };
>       Predicate predicateAdGroup = new Predicate();
>       predicate.field = "AdGroupId";
>       predicate.@operator = PredicateOperator.IN;
>       predicate.values = new string[] { adGroup.id.ToString() };
>       selectorKeyword.predicates = new Predicate[] { predicate, 
> predicateAdGroup };
>
>       // Set the selector paging.
>       selectorKeyword.paging = new Paging();
>
>       AdGroupCriterionPage page = new AdGroupCriterionPage();
>
>       selectorKeyword.paging.startIndex = 0;
>       selectorKeyword.paging.numberResults = 500;
>
>       // Get the keywords.
>       page = adGroupCriterionService.get(selectorKeyword);
>
>
> But this throws an exception at the last line of the code which is:
>
> {"[SelectorError.INVALID_PREDICATE_FIELD_NAME @ serviceSelector, 
> RequiredError.REQUIRED @ serviceSelector.predicates[1].operator, 
> RequiredError.REQUIRED @ serviceSelector.predicates[1].field]"}
>
> But we can see in the Google Api documentation that AdGroupId is a 
> filterable selective field of the Selector.
>
> Any ideas, please?
>
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords 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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/5f2bf67c-f3fc-4005-ac7e-eaadbea79d22%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to