Search code examples
google-api-java-clientgoogle-maps-engine

Facing IllegalArgumentException: key geometry with google-api-services-mapsengine


I'm using thi library "google-api-services-mapsengine" (version 1.18.0-rc) and when I try do make a select on Google Maps Engine using this code :

com.google.api.services.mapsengine.MapsEngine.Tables.Features.List aRequest = myObj.getInstance().mapsEngine.tables().features().list(ASSET_ID_USER).setMaxResults((long) 1000)
                    .setSelect("num_dept")
                    .setWhere("mail='"+email+"'");

I face this issue :

java.lang.IllegalArgumentException: key geometry
    at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:871)
    at com.google.api.client.json.JsonParser.parse(JsonParser.java:374)
    at com.google.api.client.json.JsonParser.parse(JsonParser.java:347)
    at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:87)
    at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:81)
    at com.google.api.client.http.HttpResponse.parseAs(HttpResponse.java:459)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)

Solution

  • This is an instance of this bug: https://code.google.com/p/google-api-java-client/issues/detail?id=867.

    In the meantime, the best workaround is to either include 'geometry' in your select string, or to omit it completely. Do not change the generated client library, as you may not be able to upgrade to future versions without modifying your code and you may find unexpected side effects - in this case you may not be able to retrieve the geometry field at all.

    EDIT: Oh, and Google like it when you 'star' the bugs to show that you're also affected.

    EDIT2: This bug is now fixed, so grab a recent version of the Maps Engine client library (rev44 or higher) and see how it goes.