Problem getting Label name

20 views
Skip to first unread message

di...@easyleads.com

unread,
Dec 2, 2015, 10:12:23 AM12/2/15
to AdWords API Forum
Hi,

I can't get LabelName, it's returned as null. I'm using java library v201509

LabelServiceInterface labelService = adWordsServices.get(adwordsSession, LabelServiceInterface.class);

Selector selector = new SelectorBuilder()
.fields(LabelField.LabelName)
.fields(LabelField.LabelId)
.fields(LabelField.LabelStatus)
.build();

LabelPage page = labelService.get(selector);
if (page.getEntries() != null) {
for (Label label : page.getEntries()) {
System.out.println("Label id " + label.getId() + ", label name " + label.getName() + ", label status " + label.getStatus());
}
}

I'm getting id and status, but name is null. If I add LabelField.LabelAttribute to the selector then also then status becomes null.

Thanks.

Anthony Madrigal

unread,
Dec 2, 2015, 4:55:54 PM12/2/15
to AdWords API Forum
Hi,

When using the SelectorBuilder, each time you use .fields, it overrides the previous one, so in your case the Id is overriding the Name field. Some fields, such as Status, are returned whether you select them or not, which explains why Id and Status get returned.

In order to fix your issue, change your selector to the following:
Selector selector = new SelectorBuilder()

 
.fields(LabelField.LabelName,LabelField.LabelId,LabelField.LabelStatus)
 
.build();

Cheers,
Anthony
AdWords API Team

di...@easyleads.com

unread,
Dec 3, 2015, 4:45:33 AM12/3/15
to AdWords API Forum
Thanks.

Stupid mistake of mine.
Reply all
Reply to author
Forward
0 new messages