I'm not able to receive plain text using RestyGWT. A very simple test service looks like this:
@GET
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
void test(MethodCallback<String> callback);
On the client side I always get:
Response was NOT a valid JSON document
Looking at the HTTP response I'm seeing that content type is set correctly:
Content-Type:text/plain
What's the problem? Why RestyGWT tries to parse this as JSON? Am I doing smth wrong?
Well, RestyGWT is a Json library, AFAIK it is not made to handle plain text, or XML, or anything else. "foo"
isn't a valid Json data, should be ["foo"]
or {"stuff": "foo"}
.
Indeed, in our Rest API, we tried to send pure text (an id), but we finally made a simple object wrapping the id.