Re: Re: unsupported media type

2014-07-15 Thread Fabian Mandelbaum
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 
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  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"  > > 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

RE: Re: unsupported media type

2014-07-15 Thread Frank Kolnick
It's fine if I call setEntity() and return something/anything.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3085219


RE: Re: unsupported media type

2014-07-15 Thread Frank Kolnick
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  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"  > 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


RE: Re: Re: Put with no content

2014-07-15 Thread Frank Kolnick
Thanks Thierry :-)

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3085213


Re: API World competition support

2014-07-15 Thread Xavier Méhaut
done :)


2014-07-15 21:15 GMT+02:00 Jerome Louvel :

> Hi all,
>
> Our APISpark  platform (based on Restlet
> Framework) is in 2nd position, not far from 1st, in the API Infrastructure
> category for the "API World" awards competition
> 
> .
>
> The winners will get great exposure (see this previous visual landscape
> 
> from DevNetwork that put Restlet in a nice spot close to cool developer
> technologies) and free tickets to the event based in San Francisco.
>
> I would really appreciate your support to get a boost to first place! The
> voting ends in less than 12 hours. If we win, all remaining extra tickets
> will be given out to interested supporters.
>
> Thanks!
> Jerome
> --
> http://restlet.com
> @jlouvel 
>
>
>
>
>

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3085209

API World competition support

2014-07-15 Thread Jerome Louvel
Hi all,

Our APISpark  platform (based on Restlet Framework)
is in 2nd position, not far from 1st, in the API Infrastructure category
for the "API World" awards competition

.

The winners will get great exposure (see this previous visual landscape

from DevNetwork that put Restlet in a nice spot close to cool developer
technologies) and free tickets to the event based in San Francisco.

I would really appreciate your support to get a boost to first place! The
voting ends in less than 12 hours. If we win, all remaining extra tickets
will be given out to interested supporters.

Thanks!
Jerome
--
http://restlet.com
@jlouvel 

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3085203

Re: Re: Put with no content

2014-07-15 Thread Thierry Boileau
Hello,

>Restlet now complains that the content length must be greater than or
equal to zero.
>As pointed out by other posters, this is an artificial constraint imposed
by Restlet. In many cases, the URI itself carries sufficient information.
If I have a look at the HTTP specifications (
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13), I'm
inclined to say that things are quite clear:

Content-Length= "Content-Length" ":" 1*DIGIT

Where "digit" is defined as follow (
http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2):

 DIGIT  = 

Which is only an answer to this single mail.


Don't worry, I don't forget the global topic, but unfortunately I need a
little bit time to answer you.

Best regards,
Thierry Boileau


2014-07-14 17:20 GMT+02:00 Frank Kolnick :

> I tried setting the content length to -1, as per MSDN:
> "The ContentLength property contains the value of the Content-Length
> header returned with the response. If the Content-Length header is not set
> in the response, ContentLength is set to the value -1."
>
> Restlet now complains that the content length must be greater than or
> equal to zero.
>
> As pointed out by other posters, this is an artificial constraint imposed
> by Restlet. In many cases, the URI itself carries sufficient information.
>
> I.e., please stop doing that :-)
>
> --
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3085083
>

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3085197