Note that there are some explanatory texts on larger screens.

plurals
  1. POPosting JSON to Restlet using xstream and jettison results in "Unsupported Media Type"
    primarykey
    data
    text
    <p>I am using the jse edition of Restlet 2.1.0 with the xstream and jettison extensions that enable me to have a resource that is declared like this:</p> <pre><code>@Get("json") public Customer retrieve(); </code></pre> <p>This allows me to have a client that can choose whether to get a JSON string or get a Customer object, with xstream+jettison doing the serialization/deserialization.</p> <p>I also have a resource method declared like this:</p> <pre><code>@Post public Customer store(Customer customer); </code></pre> <p>Which I can post to using something like:</p> <pre><code>clientResource.post(customer, Customer.class); </code></pre> <p>This all seems to work nicely. However the one thing that doesn't work is the simplest scenario, of posting a JSON String to this Post Restlet resource.</p> <p>When I try to post the following JSON String:</p> <pre><code>{"com.redprairie.task.common.Customer":{"firstName":"George","lastName":"Shaw","birthDate":"1856-07-26 07:00:00.0 UTC","address":"Bibbs Hall Lane, Ayot St. Lawrence, AL6 9BX United Kingdom"}} </code></pre> <p>I get this stack trace:</p> <pre><code>&lt;failure message="Unsupported Media Type (415) - Unsupported Media Type" type="org.restlet.resource.ResourceException"&gt;Unsupported Media Type (415) - Unsupported Media Type at org.restlet.resource.ClientResource.doError(ClientResource.java:612) at org.restlet.resource.ClientResource.handleInbound(ClientResource.java:1203) at org.restlet.resource.ClientResource.handle(ClientResource.java:1070) at org.restlet.resource.ClientResource.handle(ClientResource.java:1087) at org.restlet.resource.ClientResource.post(ClientResource.java:1438) at com.redprairie.task.common.rest.RestletResource.post(RestletResource.java:99) at com.redprairie.task.common.rest.ServerResourceTest.testPostMethodUsingJSON(ServerResourceTest.java:165) </code></pre> <p>I'm guessing there is something simple that I'm doing wrong, but I'm not sure what it is.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload