Access FeedItems by a Key Attribute Value

139 views
Skip to first unread message

Gazal Garg

unread,
Jun 15, 2016, 9:03:51 AM6/15/16
to AdWords API Forum

I am using Google AdWords API to manage my Product Feeds for Dynamic Remarketing. I have created a Custom Type Feed with, let's say, three Attributes.

PRODUCT_ID (key, number), PRODUCT_NAME (text), PRICE (text)

(Note PRODUCT_ID is the Key here.)

I am able to insert FeedItems to it using the API and get FeedItemId as a result of ADD operation. I can also use this FeedItemId to query FeedItem. But is it possible to query/get FeedItems by filter on one of the above attributes? In my case, can I query using the PRODUCT_ID attribute (instead of FeedItemId)?

I have read this documentation which says AttributeValues are not filterable. Although the documentation of FeedItemService says this for feedItemId:


ID of this feed item. This may be unspecified if the user-defined key attributes are specified

which sounds like user defined key can be used in place of FeedItemId and hence might become filterable. I am not able to get this to work though.

I am creating a Selector using SelectorBuilder like this:

val selector = new SelectorBuilder() .fields("FeedItemId", "AttributeValues") .equals("FeedId", feedId.toString) .build()

which returns me all the FeedItem in the given Feed. But notice how API stops working if I add an extra filter like:

.equals("PRODUCT_ID", someProductId.toString)

or

.equals("FeedItemId", someProductId.toString)

or

.equals("ID", someProductId.toString)

but it does works if I change the condition to pass FeedItemId

.equals("FeedItemId", someFeedItemId.toString)

If it is not possible to filter based on attribute values then I will have to maintain the mapping from PRODUCT_ID to FeedItemId in my database, which is doable but comes with extra maintenance cost.


Any insights you could provide is really appreciated. Thanks!


Link to stackoverflow post

Shwetha Vastrad (AdWords API Team)

unread,
Jun 15, 2016, 4:57:18 PM6/15/16
to AdWords API Forum
Hi Gazal,

I'm afraid the feed item attribute values are not filterable. Key attributes in a feed are used to maintain unique feed items based on your definition of a key. For example, you define PRODUCT_ID as a key attribute and try to add a new feed item with an existing Product_ID, you would encounter FeedItemError.KEY_ATTRIBUTES_NOT_UNIQUE. This way you can define your own unique relationship and not worry about adding possible duplicates.

I hope this helps. 

Regards,
Shwetha, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages