Search code examples
google-app-enginerestlet

Weird behavior with Restlet and GAE


I have the following piece of code with Restlet in Google AppEngine from an Android client.

ClientResource clientResource = new ClientResource(RESTLET_TEST_URL);
ProductResource productResource = clientResource.wrap(ProductResource.class);
productResource.store(mProduct);
Status status = clientResource.getResponse().getStatus();
Toast.makeText(this, "Status: "+ status.getDescription(), Toast.LENGTH_SHORT).show();
clientResource.release();

The .store() method is analogous to a PUT request. The weird thing is, this works fine when I connect to the development server but on the actual AppEngine site, nothing happens. I just get Status: OK indicating that the request went through.

I can't troubleshoot cause I can only do that in the Dev Server and that is working fine.

Any ideas on what the problem may be or how to approach this ?

For reference, the code at the server end is :

if (product != null ) {
    if (new DataStore().putToDataStore(product) ) {
    log.warning("Product written to datastore");
} else {
        log.warning("Product not found in datastore");
    }
}

This is just a simple write to the datastore using Objectify.


Solution

  • Turns out this is a known issue. See here

    The solution is to use clientResource.setEntityBuffering(true);. However, please note that this method is only available in the Release Candidate for Android Client and not in the stable release.