Issue passing an array to SelectorBuilder .in() method

13 views
Skip to first unread message

Matt Jacobson

unread,
May 13, 2019, 5:40:39 PM5/13/19
to AdWords API and Google Ads API Forum
Hello,

I am trying to create a Selector like so:
String[] adGroupIds = {"123", "234"};
SelectorBuilder builder = new SelectorBuilder();
Selector selector = builder
       
.fields(AdGroupField.values())
       
.in(AdGroupField.Id, adGroupIds)
       
.offset(offset)
       
.limit(pageSize)
       
.build();

However when I pass the Selector to the AdGroupServiceInterface I get an INVALID_PREDICATE_VALUE and the resulting SOAP request seems to be malformed:
<predicates>
   
<field>Id</field>
   
<operator>IN</operator>
   
<values>123,234</values>
</predicates>

Furthermore, if I change the .in() method to use a varargs instead everything works as expected:
SelectorBuilder builder = new SelectorBuilder();
Selector selector = builder
       
.fields(AdGroupField.values())
       
.in(AdGroupField.Id, "123", "234")
       
.offset(offset)
       
.limit(pageSize)
       
.build();

and I get the proper SOAP request:
<predicates>
   
<field>Id</field>
   
<operator>IN</operator>
   
<values>123</values>
   
<values>234</values>
</predicates>

I was under the assumption that Java treated varargs the exact same as arrays but something seems to be different here.

Any help would be greatly appreciated.

Thanks!

googleadsapi...@google.com

unread,
May 14, 2019, 3:10:42 AM5/14/19
to adwor...@googlegroups.com
Hi Matt,

Thank you for contacting support. However, your question appears to be more related to the Java client library. You may reach out to the client library owners directly via this link for further assistance.

Best regards,
Peter
Google Ads API Team

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@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+unsubscribe@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/632e47ab-7a2d-4ce2-81af-65c98d4efc59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages