1 Reply Latest reply on Dec 27, 2012 5:45 AM by ravinandan

    Can't access to REST. HTTP 400 error.

    pierre laurent Newbie

      Hi There,

       

      I do have some troubles using guvnor, especially getting rest informations.

      Using windows, i downloaded a drools-5.1.1-guvnor-standalone version. ( testing on a war 5.5 deployed on a tomcat 6 server does the same)

      Accessing web site using http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/ is ok.

      I can do whatever i want.

       

      I want to check if it is possible to get some information using REST services in ATOM format.

      On this case, list of packages is the goal.

       

      The only thing i can get is an HTTP 404 or HTTP 500 depending on the client path.

       

      Can someone point me in the right direction ?

       

      String guvnorHost = "localhost";

              String guvnorPort = "8080";

              String packageName = "com.rules";

              String assetName = "car";

              String asset = "car";

              String authorizationHeader = "Basic " + org.apache.cxf.common.util.Base64Utility.encode("guest:".getBytes());

             

             

              WebClient client = WebClient.create("http://" + guvnorHost + ":" + guvnorPort);

       

              MultivaluedMap<String, String> map = new MetadataMap<String, String>();

       

              List<String> slugHeader = new ArrayList<String>();

       

              //slugHeader.add(assetName);

       

              List<String> authHeader = new ArrayList<String>();

       

              authHeader.add(authorizationHeader);

       

              List<String> contentTypeHeader = new ArrayList<String>();

       

              contentTypeHeader.add("application/octet-stream");

       

            //  map.put("Slug", slugHeader);

       

              map.put("Authorization", authHeader);

       

              map.put("Content-Type", contentTypeHeader);

       

              client.headers(map);

             

              System.out.println(client.toString());

       

             

              Response response = client.path("/drools-guvnor/rest/packages/").accept("application/atom+xml").get();

            System.out.println(response.getStatus());

              System.out.println(response.getEntity().toString());

       

      Kind regards,

       

      Pierre