Thursday 2 December 2021

RESTEASY004590: You must define a @Consumes type on your client method or interface, or supply a default

Just a small note on the above error message.

I was a bit at a loss what I had done wrong.

For example:

@GET
@Path("/{category}")
@Produces("application/json")
public Response getItemDefinition(@PathParam("category") String category, String filterOn);

And I got the following error message:

RESTEASY004590: "You must define a @Consumes type on your client method or interface, or supply a default

It took me a couple of hours to find the problem, but when it hit me, it hit me hard.

Can you spot it?

Solution: I forgot to put in a @QueryParam("filterOn") annotation on the "filterOn" argument. This causes the rest client to interpret the "filterOn" field as being where to put the Body of the response. And for that, it needs a @Consumes annotation, to find out what to put there.

It seems obvious afterwards, but sometimes little mistakes take a lot of time to find.

No comments:

Post a Comment