facebook

How to prepare JSON object for REST web service consumption?

  1. MyEclipse Archived
  2.  > 
  3. Web Services
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #311167 Reply

    emranrao
    Member

    Considering the following simple REST webservice,

        @POST
        @Path("add")
        @Produces("text/plain")
        @Consumes("application/json")
        public String addMonitor(JSONObject jsonObject) {
            return "Object received";
        }

    I am trying to send a JSON object and testing my code with REST Web Service Explorer but I’m getting the following error:

    SEVERE: A message body reader for Java type, class net.sf.json.JSONObject, and MIME media type, application/json;charset=UTF-8, was not found

    I have tried sending an object as following:

    JSONObject object=new JSONObject();
            object.put("Company_Name","CHOICEPOINT PRG");
            object.put("Account_Name","ADMIN");
            object.put("Transaction_ID","11111:PWJ-20100831-01");
            object.put("Start_DateTime","2010-08-31 09:07:48");
            object.put("Product_Type","DISCOVERY");
            object.put("Duration","3935");
            object.put("Status","Pass");
            object.put("Work_Flow_Identifier",XXXXXXX");
            object.put("Server_Node","XXXXX-XXX-LINUX-1");

    I have also tried sending it in the following format but same error:

    {"Company_Name":"XXXXXXXX","Account_Name":"ADMIN","Transaction_ID":"11111:PWJ-20100831-01","Start_DateTime":"2010-08-3109:07:48","Product_Type":"DISCOVERY","Duration":"3935","Status":"Pass",
    "Work_Flow_Identifier":"XXXXXXX","Server_Node":"XXXXXXXXXXXXX"}

    How do I prepare my JSON object for this web service consumption that I can test with REST Web Service Explorer? What am I doing wrong?

    Thanks,
    Emran

Viewing 1 post (of 1 total)
Reply To: How to prepare JSON object for REST web service consumption?

You must be logged in to post in the forum log in