AnsweredAssumed Answered

REST calling problem

Question asked by sarkar92 on Jul 8, 2013
Latest reply on Jul 9, 2013 by frederikheremans1
I have successfully installed activiti for dev environment.
We use activiti-rest  in our application.
But now whenever I try to start a simple process I am getting "Bad Request (400) - Bad Request".
Here is my code …


public static ClientResource getClientResource(String uri,String userName,String password) {
      System.out.println("in getClientResource password:"+password);
               ClientResource clientResource = new ClientResource(uri);
               clientResource.setChallengeResponse(ChallengeScheme.HTTP_BASIC,userName, password);
               return clientResource;
}

public static String startRequestedProcess(HashMap<String,Object> param,String userName,String password)
      throws Exception {
          String uri = "http://localhost:9090/activiti-rest/service/runtime/process-instances";
           JSONObject object=new JSONObject();
           Set s=param.keySet();
          Iterator<String> itr= s.iterator();
              while(itr.hasNext())
              { 
                                String key=itr.next();
                object.put(key, param.get(key));
                System.out.println(key +" "+param.get(key));
             }
   
           Representation rep = new JsonRepresentation(object);
           rep.setMediaType(MediaType.APPLICATION_JSON);
           JSONObject jsObj = new JSONObject(getClientResource(uri,userName,password).post(rep).getText());
           logger.info("Returning processId " + jsObj.getString("id"));
           return jsObj.getString("id");
   }

   public static void main(String args[]) throws Exception{
         try{
      HashMap<String, Object> param = new HashMap<>();
      param.put("processDefinitionKey", "testRestProcess");
      startRequestedProcess(param,"caadmin","P@ssw0rd");
      
      }catch(ResourceException e){   
         System.out.println("===== > "+e.getMessage());
         System.out.println("===== >"+e.getStatus());   
      }


is something wrong in my code??

Outcomes