Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass JSON object to server from RESTful client in java
    primarykey
    data
    text
    <p>I'm creating a web application. I want to do the admin operations using Java SE application. To do that I created a RESTful <code>ShoppingAdminClient</code> in my SE project. I need to pass an JSON object to the server from client. I tried with this,</p> <pre><code> public static void main(String[] args) throws JSONException { ShoppingAdminClient sac = new ShoppingAdminClient(); JSONObject jo = new JSONObject(); jo.put("itemName", "Itemms"); sac.create_JSON(jo); } </code></pre> <p>But I got the following exception,</p> <pre><code>Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class shoppingadmin.Item, and MIME media type, application/json, was not found at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:149) at com.sun.jersey.api.client.Client.handle(Client.java:648) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:670) at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:563) at shoppingadmin.ShoppingAdminClient.create_JSON(ShoppingAdminClient.java:69) at shoppingadmin.ShoppingAdmin.main(ShoppingAdmin.java:27) Caused by: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class shoppingadmin.Item, and MIME media type, application/json, was not found at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:288) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:204) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:147) ... 6 more Java Result: 1 </code></pre> <p>How do I pass a JSON type object to server?</p> <p>Thanks in Advance!</p>
    singulars
    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.
 

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