4 Replies Latest reply on May 9, 2014 2:23 AM by Maciej Swiderski

    Issue Authenticating to Kie Rest Service

    Tim McClure Apprentice

      I got the code below from the link above it - recent code so it should work but for some reason I get an authentication error when I execute it using admin/admin however I can log in on the web page using the same credentials.  I get a 401 error - I know it must be something stupid I am doing - is there something I need to change in the JBoss configuration for my url: Localhost:8080/kie-wb?

       

      <html><head><title>JBoss Web/7.0.13.Final - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - Validation fails.</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Validation fails.</u></p><p><b>description</b> <u>This request requires HTTP authentication (Validation fails.).</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.0.13.Final</h3></body></html>

       

       

      http://simplesassim.wordpress.com/2013/07/07/how-to-list-assets-with-the-drools-guvnor-rest-api/

       

      package com.apimg.com.dakota;

      import javax.ws.rs.client.Client;

      import javax.ws.rs.client.ClientBuilder;

      import javax.ws.rs.core.Response;

      import org.glassfish.jersey.client.filter.HttpBasicAuthFilter;

       

      public final class KiePackage {

        public static void main(final String[] args) {

         final Client client = ClientBuilder.newClient();

           client.register(new HttpBasicAuthFilter("admin", "admin"));

           final Response res = client.target("http://localhost:8080/kie-wb/rest/packages").request().get();

           System.out.println(res.readEntity(String.class));

           client.close();

        }

       

      }