Hi,

I was trying to retrieve all Ad fields for Ads inside an AdGroup. If my 
AdGroup has multiple ads, say for example 5 ads each one is of different 
type like Expanded Text Ad, MultiAssetAd etc.,

Now, I collect all the AdIds inside an AdGroup and pass it to the selector, 
I am getting INVALID_FIELD_NAME exception.

Sample code:

public static List<Ad> loadAds(
      AdWordsServicesInterface adWordsServices, AdWordsSession session, 
Collection<String> adIds) {


    AdServiceInterface adService = adWordsServices.get(session, 
AdServiceInterface.class);


    List<Ad> ads = new ArrayList<>();


    int offset = 0;


    // Create selector.
    SelectorBuilder builder =
        new SelectorBuilder()
            .fields(AdField.values())
            .in(AdField.Id, adIds.toArray(new String[0]))
            .offset(offset)
            .limit(PAGE_SIZE_LIMIT);


    AdPage page = new AdPage();
    do {
      // Get campaigns.
     // page = withRetryPolicy(() -> adService.get(builder.build()));


      try {page = adService.get(builder.build());} catch (RemoteException e
){// TODO Auto-generated catch block
  e.printStackTrace();}
      if (page.getEntries() != null) {
        ads.addAll(Arrays.asList(page.getEntries()));
      }


      offset += PAGE_SIZE_LIMIT;
      builder.increaseOffsetBy(PAGE_SIZE_LIMIT);
    } while (offset < page.getTotalNumEntries());


    return ads;
  }

How can I retrieve all the AdFields?

Suresh

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/7589d7f4-a6b4-4758-926d-2e1c7fb27aee%40googlegroups.com.

Reply via email to