Getting an Exception when calling look()

I follow the direction below, as recommended by Looker, to generate my Java SDK:

I am able to successfully call on allLooks(), and runLook() just fine. However, when I call on look(), I am getting this exception:

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token
at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@3b77a04f; line: 1, column: 3798] (through reference chain: io.swagger.client.model.LookWithQuery[“query”]->io.swagger.client.model.Query[“vis_config”])

My sample Java code:

private void resetFilters(LookApi lookApi, ArrayList<LooksData> looks) {		

    try {
    	
    	LookWithQuery thisLook = lookApi.look(Long.valueOf(50), null); 
    	
    } catch (Exception e) {        	
    	System.out.println("Exception: " + e);        
    }    	
	
}

I looked at the generated Java classes and it appeared that the LookWithQuery class contains Query which has visConfig defined as:

private Map<String, String> visConfig = new HashMap<String, String>();

I am thinking that may be the exception is resulted from the returned json containing visConfig not being a map of String,String?

Has anyone see this error before?

I think you actually may have to nest with parentheses. So query(vis_config). I am admittedly not totally sure about that, but see if it resolves and let us know!

Hello Izzy,

Thank you for responding back.

Can you clarify further on your suggestion?

So, the LookApi class has the method look() defined as followed:

public LookWithQuery look(Long lookId, String fields) throws ApiException

The returned LookWithQuery class contains the Query object as:

public class LookWithQuery {
private Query query = null;

The Query class defines visConfig as:

public class Query {
private Long id = null;
private Map<String, String> visConfig = new HashMap<String, String>();

Note that all of the above classes are generated automatically by swagger-codegen. How are you suggesting I should change?

1 Like

I’m seeing the same problem. It looks like vis_config is a map rather than a string, like the swagger generated SDK expects. I’m interested in learning a good solution too.

Just checked in with our engineers, and it looks like this is related to a bug we’re working on fixing. Basically, the collection is tagged as a string in the API spec that feeds the generator, when really it’s a JSON object that’s being passed as a string. It’s on us to correct that type annotation so that it functions as expected, and we’re working on it.

In the meantime, you could try explicitly converting that part of the payload with a different deserializer.

I’ll update here when it’s fixed/released.