I posted this question to the wrong list, where it might not be noticed or 
addressed, so I'm re-posting it here; please excuse the duplication.

I have a ServerResource that can produce three variants in response to a GET: 
application/json, application/xml, and text/plain.  I want the JSON variant to 
be preferred over the others, so that in the absence of a specific request (via 
the "Accept" header) for another variant, the JSON representation and 
"application/json" Content-Type will always be returned.

I'm having trouble achieving this in Restlet 2.0.0.  Unless the client 
explicitly passes "Accept: application/json", the Variant presented to the 
get(Variant) method is always application/xml.  This happens when the "Accept" 
list includes "*/*" and also when no "Accept" header is sent at all.

I've experimented with using @Get annotations with variants specified as 
parameters to the annotation (@Get('json'), @Get('xml'), @Get('txt')), as well 
as with get(Variant), but the result is the same: the xml variant is always 
preferred.

I've overridden getPreferredVariant() to indicate that application/json is 
preferred, but it makes no difference (nothing ever causes that method to be 
invoked anyway).

How can I make application/json be the default while still returning 
application/xml if that's explicitly requested by the client?

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

Reply via email to