googleads / googleads-java-lib

Google Ad Manager SOAP API Client Library for Java
Apache License 2.0
226 stars 360 forks source link

Issue passing an array to SelectorBuilder .in() method #175

Closed matthewjacobson closed 5 years ago

matthewjacobson commented 5 years ago

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.

nwbirnie commented 5 years ago

Hey, I couldn't recreate this on my installation. Are you sure that the code example above matches what's actually being sent at runtime?