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.
source share