I'm having problem with Restlet client call to a working rest service:
final ClientResource resource = new ClientResource(Routes.PUBLIC_STORE_API);
resource.setOnResponse(new Uniform() {
public void handle(Request request, Response response) {
try {
Status status = response.getStatus();
if(!Status.isError(status.getCode())){
String jsonResponse = response.getEntity().getText();
} else {
// Handle error
}
} catch (Exception e){
callback.failure(new Throwable(e.getMessage()));
}
}
});
JsniHelper.consoleLog("Adding object id=" + id + " type=" + type + " data=" + jsonObject);
resource.getReference().addQueryParameter("type", type);
resource.getReference().addQueryParameter("id",id);
resource.post(jsonObject, MediaType.APPLICATION_JSON);
At the point of log above the object is a valid JSON string.
The Restlet ServerResource
is able to get both the id
and type
Strings however the entity is always null
:
@Post("json")
public Representation add(Representation entity){ // omitted }
I tried to use CURL and the Rest service was able to process the JSON string properly.
What could be the problem with my code in GWT?
Update: I have this in the POM
<dependency>
<groupId>org.restlet.gae</groupId>
<artifactId>org.restlet.ext.gwt</artifactId>
<version>2.2-RC3</version>
</dependency>