AnsweredAssumed Answered

Getting error on deploying the process definition in activiti-rest using java code

Question asked by mdnoorshid on Jul 30, 2016
Latest reply on Aug 3, 2016 by mdnoorshid
Hi all i am trying to deploy process definiton in activiti-rest by using java class.But getting error as 'Exception in thread "main" Bad Request (400)'.I have tried a lots in google but not found any solution for that.Please help me where is the actual fault in my code.Find below my java code and errors.

My Java Code
=========
/**
*Client Resource
*/
private static ClientResource getClientResource(String uri){
   ClientResource resource=new ClientResource("http://localhost:8431/activiti-rest/service");
   resource.setChallengeResponse(ChallengeScheme.HTTP_BASIC,kermit,kermit);
   return resource;
}

/**
* Creating Deployment
*/
public static JSONObject createdeployment(){
   String uri=REST_URI+"/repository/deployments";
   log.debug("uri(Create Deploymnet):: "+uri);
   JSONObject my_data=new JSONObject();
   try {
      my_data.put("name","BuyTicket.bpmn20.xml");
      Representation response=getClientResource(uri).post(my_data);
      JSONObject object=new JSONObject(response.getText());
      if(object!=null){
        log.info("Deployed Successfully…..");
        return object;
      }
      
   } catch (JSONException e) {
      e.printStackTrace();
   } catch (IOException e) {
      e.printStackTrace();
   }
   return null;
}

My Errors console
============
 
Starting the internal HTTP client
Exception in thread "main" Bad Request (400) - The request could not be understood by the server due to malformed syntax
   at org.restlet.resource.ClientResource.doError(ClientResource.java:590)
   at org.restlet.resource.ClientResource.handleInbound(ClientResource.java:1153)
   at org.restlet.resource.ClientResource.handle(ClientResource.java:1048)
   at org.restlet.resource.ClientResource.handle(ClientResource.java:1023)
   at org.restlet.resource.ClientResource.post(ClientResource.java:1485)
   at org.restlet.resource.ClientResource.post(ClientResource.java:1424)
   at com.bizruntime.activiti.rest.Activiti_Rest_BuyEconomyOrBusinsessClassTIcket.TicketClass.createdeployment(TicketClass.java:40)
   at com.bizruntime.activiti.rest.Activiti_Rest_BuyEconomyOrBusinsessClassTIcket.Ticke_Test.main(Ticke_Test.java:13)

Outcomes