Starting with v201806 all targeting fields were removed from FeedItem . The 
Migration 
Guide 
<https://developers.google.com/adwords/api/docs/guides/migration/v201806> 
says we should use the FeedItemTargetService to access the targeting info. 
I wrote a test program to see if I could access the existing targeting info 
using the FeedItemTargetService. Specifically I want to fetch schedules and 
devicePreference. Using the old API, these were returned with the FeedItems 
themselves. Testing with the new API, I am not able to fetch any of the 
existing targeting for Sitelinks that we know should have it.

Here is a sample of the code I am using to try to fetch all 
FeedItemTargets. Even though we should get some items back, the result 
comes back empty.

    public Map<String, List<FeedItemTarget>> getFeedItemTargets(Account 
account) throws Exception

    {

FeedItemTargetServiceInterface service = 
BaseManager.getFeedItemTargetService(account.getId());


String[] fields = { 

"FeedId",

"FeedItemId",

"TargetType",

"Status",

"AdGroupId",

"CampaignId",

"CriteriaType",

"PlatformName",

"StartHour",

"StartMinute",

"EndHour",

"EndMinute",

"DayOfWeek",

"AdGroupName",

"CampaignName",

"TargetingStatus"};


StringBuilder awql = new StringBuilder();

awql.append("SELECT " + Utils.makeList(fields, ","));

awql.append(" WHERE FeedId=" + sitelinkFeed.getFeedId());


        int chunkSize = 500;

     Map<String, List<FeedItemTarget>> targetMap = new HashMap<>();


        int count = 0;

     

        for(;;){

            FeedItemTargetPage page = service.query( awql + " LIMIT " + 
count + "," + chunkSize);


            FeedItemTarget[] targets = page.getEntries();

            if( targets == null ) break;

            

            for( FeedItemTarget target: targets ) {

             String feedItemId = target.getFeedItemId().toString();

             List<FeedItemTarget> lst = targetMap.get(feedItemId);

             if (lst == null) {

             lst = new ArrayList<>();

             targetMap.put(feedItemId, lst);

             }

             lst.add(target);

                ++count;

            }

        }

        

        return targetMap;

    }


Are there any examples of how to migrate from the old FeedItemService to 
the FeedItemTargetService to *fetch* existing targeting? I know the code 
includes examples of how to create or update feed item targets using the 
new service, but it's not clear to me how to migrate existing targeting 
info.


Thanks!

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/b3872ec4-ee28-43cc-b621-58d2dd921233%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • ... Mario Garcia
    • ... 'Peter Oliquino (AdWords API Team)' via AdWords API and Google Ads API Forum

Reply via email to