RE: Re: can not return description in put
Hi, The put method is being called, so overriding is working i assume. Overriding the put (representation, variant) is not working, then the put call is not handled. Which i can understand because i do not use negotiation and therefore this version of the put method should not be called. I tried the apache http client library to call my server. That shows that het get acutually returns in the http statusline the reasonphrase i have set. By switching to the put, the reasonphrase replaces my msg with the default description of the status code. At least now i know for sure that it is the server which is not sending the correct reasonphrase. Still leaves the problem of how to pass my msg to the client from a put I do not use the annotations, because i want to have more control over the processing flow. Mixing the two unfortunately does not work. It produces an internal server error ;-) Any other ideas? Bram -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2767335
RE: Re: can not return description in put
Nop, unfortunately both options produce the same result. The clientresource.getStatus().getDescription() call on a Get returns my message from the setStatus at the server The clientresource.getStatus().getDescription() call on a Put returns the description of the status error code (400 - Bad request) instead of my message. Any further ideas how to fix this? -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2766233
can not return description in put
Hello list, Can you explain to me how to return a description with a client_error status in a PUT handler? Things are working in the GET handler, but for some reason i can not get it working in the put. In the client the error_code is available, but my description Payload is not in JSON format is not. The description from the GET is available. public class MyServerResource extends ServerResource { @Override protected Representation get() { Representation representation = null; MediaType returnMediaType = getPreferredMediaType(); if (MediaType.APPLICATION_JSON.equals(returnMediaType)) { representation = getCSV(); } else { setStatus(Status.CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE, Can only support application/json); } return representation; } @Override protected Representation put(Representation representation) { // check if the requested mediatype is application/json if (MediaType.APPLICATION_JSON.equals(representation.getMediaType())) { JsonRepresentation jsonRepresentation = new JsonRepresentation(representation); if (jsonRepresentation == null) { setStatus(Status.CLIENT_ERROR_BAD_REQUEST, Payload is not in JSON format); } else { // other stuff } } return null; } } This e-mail and its contents are subject to the DISCLAIMER at http://www.tno.nl/emaildisclaimer -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2765366