RESTEasy Client: Object Restore

I play with RESTEasy to use REST services and I am trying to use the Twitter search API.

So, I create this interface:

public interface SimpleClient { @GET @Path("search.json") @Produces("application/json") ClientResponse<Set<String>> getSearchResults( @QueryParam("q") String hashtag, @QueryParam("result_type") String resultType ); } 

and called it with:

 SimpleClient client = ProxyFactory.create(SimpleClient.class,"http://search.twitter.com/"); ClientResponse<Set<String>> response = client.getSearchResults("#wowodc","recent"); System.out.println(response.getEntity(Set.class)); 

But I get:

ClientResponseFailure: cannot find MessageBodyReader application type content / json; charset = "utf-8" and enter the interface java.util.Set

I tried using POJO instead of java.util.Set, but I get the same exception. The only thing that did not throw an exception was to use String instead of Set.

After reading some sample code on the Internet, I thought that Set or POJO as an entity type would work, but this is not for me. The Twitter request did the right thing.

+4
source share
1 answer

You need to make sure that you have enabled the RESTEasy provider, which can cancel JSON responses. Where you can use the Jackson parser library, it is described in the docs here .

+2
source

All Articles