cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti REST API

ncoonghe
Champ in-the-making
Champ in-the-making
Hi I have deployed the REST war file and using the default users created by the deployment

I am unable to login. I tried putting the url on the Browser I got the user/password prompt for basic authentication I entered the correct credential as in the DB, but it wouldnt authenticate me

Also I tried using JAX-RS REST API to authenticate but it gives be a 401

java.lang.RuntimeException: Failed : HTTP error code : 401
   at TestClient.main(TestClient.java:20)




Below is the code
public static void main(String args[]) {
   
    try {
     
      Client client = ClientBuilder.newBuilder().property("authentication.mode", "Basic").property("username", "kermit").property("password", "kermit").build();
     // .property("authentication.mode", "Basic").property("username", "kermit").property("password", "a2VybWl0");

      WebTarget webResource = client
         .target("http://localhost:8080/activiti-rest/repository/deployments");

     Response response =  webResource.request().accept("application/json").get();
  
      if (response.getStatus() != 200) {
         throw new RuntimeException("Failed : HTTP error code : "
          + response.getStatus());
      }

      String output = (String)response.getEntity();

      System.out.println("Output from Server …. \n");
      System.out.println(output);

    } catch (Exception e) {

      e.printStackTrace();

    }
  }
3 REPLIES 3

ncoonghe
Champ in-the-making
Champ in-the-making
Can someone please help me out here ?

trademak
Star Contributor
Star Contributor
We use default basic auth for our REST API. I'm not familiar with the code you are using here. It's difficult to say much more based on the information provided.

Best regards,

ncoonghe
Champ in-the-making
Champ in-the-making
Thx for responding. I have figured the issue. Just FYI the above code reflects the JAX-RS (Rest Client API reference implementation usage)