Existing FeedItem Targeting not available with API v201806

47 views
Skip to first unread message

Mario Garcia

unread,
Aug 2, 2018, 2:07:19 AM8/2/18
to AdWords API and Google Ads API Forum

Starting with v201806 all targeting fields were removed from FeedItem . The Migration Guide 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 accountthrows 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();

            iftargets == null ) break;

            

            for( FeedItemTarget targettargets ) {

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

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

             if (lst == null) {

             lst = new ArrayList<>();

             targetMap.put(feedItemIdlst);

             }

             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!

Peter Oliquino (AdWords API Team)

unread,
Aug 2, 2018, 4:30:15 AM8/2/18
to AdWords API and Google Ads API Forum
Hi Mario,

So I can further investigate as to why you are unable to fetch your FeedItemTargets, could you provide to me your clientCustomerId and the complete SOAP request and response? You may reply to me using the Reply privately to author option.

Thanks and regards,
Peter
AdWords API Team
Reply all
Reply to author
Forward
0 new messages