tags:

views:

89

answers:

2

Hello everybody,

i've started to introduce myself into REST. I use as REST-framework Restlet. I have defined a resource with methods for the GET with several response formats like

@Get("xml")
@Get("json")

I now want to test my defined response-formats with my browser, but I don't know which parameter I have to specify in my URL to get the format. Something like:

http://localhost:8182/members?type=xml

I've tried some param-names, but I couldn't find the right param-name. I know that there must be such a parameter, because I've seen it already in an URL, but i forgot the name and couldn't find it in the net. How is the name of this parameter when using restlet?

I would be pleased, if somebody can help me, thanks, Martin

+2  A: 

Try setting the "Accept" header in your request to "text/xml" or "text/json".

I also thought if you wanted to return a resource in a certain mime-type you used the @Produces("text") annotation, not the @GET (unless this is the new way). Hmm..I see according to the API you can do it with the @GET.

I believe the URI parameter you are looking for is ?media=json

Gandalf
+1  A: 

Martin uses the Restlet API which defines its own simpler annotations (such ash @Get). The Restlet Framework does support JAX-RS API and annotations (such as @GET, @Produces, etc.) but as part of an extension.

To select the media type in your browser you need to use the "media=xml" query parameter instead of "type=xml", but this can be configured in the TunnelService of your Restlet Application instance.

Hope this helps. For further help, please use the Restlet mailing list: http://www.restlet.org/community/lists

Best regards

Jerome Louvel