The trouble is that resource interfaces aren't general Java interfaces;
they must be compatible with HTTP methods.

You have two methods annotated with @Get("json"), neither of which is a
valid target for @Get. @Get should only annotate no-arg methods that return
an object reference, @Post should only annotate one-arg methods, and so on.

In addition, there should be at most one @Get operation per metadata
argument (and at most one with no argument) on a resource interface.

You can achieve something of the effect that you're looking for by
designing your resources' URIs so that what you model as arguments to your
get method are actually encoded as part of the URI, either as query
parameters or as components of the path.

And while I understand that you are just experimenting in your example, I
do recommend reading (if you haven't already) books on RESTful or
resource-oriented design.

Read this exchange for more details:

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


--tim


On Sun, Aug 19, 2012 at 10:48 PM, Bubba 42 <bubba424...@gmail.com> wrote:

> Greetings guys,
>
> I've skimmed through the tutorials and seem to have been able to grasp how
> to stuff I'd consider intermediate however I'm still have trouble getting a
> simple REST API to work. To learn Restlet I decided to implement a simple
> interface
>
> I want to implement this interface:
>
> public interface ArithmaticResource {
>
>
>  @Get("json")
>
> public int add (int n0, int n1);
>
>
>  @Get("json")
>
> public int add (int n0, int n1, int n2);
>
>
> }
>
>
>
> However when I:
>
>
> final ClientResource cr = new ClientResource(
>
> "http://localhost:8182/restlet/arithmetic";);
>
> final ArithmaticResource resource = cr.wrap(ArithmaticResource.class);
>
> System.out.println("resource.add(1, 2) " + resource.add(1, 2));
>
> I get the following:
>
>
>   Unsupported Media Type (415) - Unsupported Media Type
>
>
> I suspect my understanding is lacking ... I'm really trying to use this
> like Cherry.py where I expose methods ... I guess that's probably not how
> to use Restlet.
>
>
> Would appreciate any help -- have been stuck on this for hours.
>
>
> Bubba424242
>

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

Reply via email to