AnsweredAssumed Answered

Deserialize list of Nodes

Question asked by dadamia on May 23, 2018
Latest reply on May 25, 2018 by dadamia

Dear Friends

 

I Get List of Nodes, then I can not deserialize json response, I get Error

 

com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class com.alfresco.client.api.common.representation.ResultPaging<com.alfresco.client.api.core.model.representation.NodeRepresentation>]: can not instantiate from JSON object (need to add/enable type information?)

 

 

 

 

Here is my code

 

 

HttpClient httpClient = HttpClientBuilder.create().build();
HttpGet get = new HttpGet("http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-shared-/children");
String alfrescoUser = "admin";
String pass = "admin";
UsernamePasswordCredentials creds = new UsernamePasswordCredentials(alfrescoUser, pass);
get.setHeader("Accept", "application/json");
get.setHeader("Content-type", "application/json");
get.setHeader(new BasicScheme().authenticate(creds, get, null));
HttpResponse response = httpClient.execute(get);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != 200)
{
throw new RuntimeException("Failed with HTTP error code : " + statusCode);
}
HttpEntity httpEntity = response.getEntity();
String apiOutput = EntityUtils.toString(httpEntity);
System.out.print(apiOutput);
Long total = null;
ObjectMapper om = new ObjectMapper();
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
ResultPaging<NodeRepresentation> nodes = null;

nodes = om.readValue(apiOutput, new TypeReference<ResultPaging<NodeRepresentation>>() {});

 

 

 

 

Please, can you Help me?

Outcomes