bitstorm / Wicket-rest-annotations

Annotations for Wicket to build REST-based API
Apache License 2.0
8 stars 6 forks source link

Don't use GsonSerialDeserial anymore - POST requests fail #3

Open wtfiwtz opened 9 years ago

wtfiwtz commented 9 years ago

AbstractRestResource<JsonWebSerialDeserial> is now the best object for JSON - not GsonSerialDeserial.

I mention this because I just spent quite a while trying to work out why a POST request was not working. HttpUtils.readStringFromRequest( ) returns an empty string on Tomcat (as the getReader() has already been emptied).

Hopefully this saves someone else some time.

Correct example code here:

https://github.com/wicketstuff/core/blob/master/jdk-1.7-parent/wicketstuff-restannotations-parent/restannotations-examples/src/main/java/org/wicketstuff/rest/resource/PersonsRestResource.java

Sample POST request for me using curl:

 curl -X POST -d @data.txt http://localhost:8081/api/v1/sample/persons --header "Content-Type:application/json"

Where data.txt is something like: {'name': 'string'}

Cheers, Nigel

wtfiwtz commented 9 years ago

Actually I think this issue was caused by a missing parameter to curl: --header "Content-Type:application/json"

The error message is something like No suitable method found. URL 'api/v1/sample/persons' and HTTP method POST