Usually you just: return someRepresentation; // This should automatically set status to HTTP 200 (OK)
or: setStatus(Status.SUCCESS_CREATED); // Set status to HTTP 201 return someRepresentation; where "someRepresentation" is the representation for the response you want to return for the PUT request. Good luck. On Tue, Jul 15, 2014 at 5:38 PM, Frank Kolnick <reallyfr...@hotmail.com> wrote: > OK, I get it now: I have to get the content via a 'data' parameter, not by > calling getEntity() :-) > > It now *almost* works perfectly. > > I.e., my update method is called, I get the right data, I set the return > status to 'SUCCESS_OK' and I'm done. But the client gets a 'no content' > code. > > I'm calling: > > Response response = getResponse(); > response.setStatus ( Status.SUCCESS_OK, "Test" ); > > Is this not the proper way to do it? > > Thanks Fabian! > > > Euh... I'm sorry but then the problem must be somewhere else. > > > > I use @Put all the time, handling the different media types myself, and I > > only got HTTP 415 when my own-written code explicitly threw > > ResourceException(Status.CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE). > > > > can you please try this on your ServerResource (or extending) class: > > > > @Put > > public void handlePut(Representation data) { > > if (data == null) { > > throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST); > > } else { > > getLogger().info(String.format("Got PUT with media type %s", > > data.getMediaType())); > > } > > } > > > > a PUT with no data in the request body should give you HTTP 400 > > a PUT with some data in the request body should give you a log entry with > > the request body media type. > > > > If that still does not work try adding the following method to that > class: > > > > @Override > > protected void initResource() { > > getVariants().add(MediaType.ALL); // I never had to use this, IIRC this > > is */* > > } > > > > Good luck! > > > > > > > > On Mon, Jul 14, 2014 at 3:03 PM, Frank Kolnick <reallyfrank at hotmail > dot com> > > wrote: > > > > > Unfortunately, that does not appear to be the case. I.e., that's where > I > > > started, and was getting the error. I tried the variations in order to > fix > > > the problem, so far without success. > > > > > > > @Put > > > > > > > > should be enough to tell Restlet to accept anything > > > > El jul 14, 2014 1:16 PM, "Frank Kolnick" <reallyfrank at hotmail dot > > > com> escribió: > > > > > > > > > I have tried sending (PUT) with a content-type of "text/plain" > > > (verified > > > > > via Fiddler). On the server side, I have tried: > > > > > > > > > > @Put("text/plain") > > > > > > > > > > @Put("text") > > > > > > > > > > @Put("plain") > > > > > > > > > > > > > > > I still get the media error in all cases. > > > > > > > > > > What am I doing wrong? Can I tell Restlet to accept *anything*? > > > > > > > > > > ------------------------------------------------------ > > > > > > > > > > > > > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3085086 > > > > > > > > > > > ------------------------------------------------------ > > > > > > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3085090 > > > > > > > > > > > -- > > Fabián Mandelbaum > > IS Engineer > > ------------------------------------------------------ > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3085217 > -- Fabián Mandelbaum IS Engineer ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3085225