I'm using RESTEasy and more specifically, the client side of their framework.
I'm calling a third part web service that's returning me some JSON code.
But, for some good reasons, the content-type in their response is "text/javascript".
How can I tell RESTEasy that it should be using a JSON provider (unmarshalling purposes) for a "text/javascript" content-type ?
Is that possible ?
My code :
public interface XClient {
@GET
@Produces("application/json")
@Path("/api/x.json")
public Movie getMovieInformation(
@QueryParam("q") String title);
}
What an solution could be like :
public interface XClient {
@GET
@Produces("text/javascript")
// Tell somehow to use json provider despite the produces annotation
@Path("/api/x.json")
public Movie getMovieInformation(
@QueryParam("q") String title);
}
I solved by using an interceptor that replaces incoming content type, like this:
I'm running out of time, so this did the trick for me. I've marked the response from the server as String, and I've manually handle the unmarshall with Jackson :
and, in my REST call :
Please advise if this is not the better solution. But this seems to work.