cancel
Showing results for 
Search instead for 
Did you mean: 

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

mdnoorshid
Champ in-the-making
Champ in-the-making
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)

3 REPLIES 3

mdnoorshid
Champ in-the-making
Champ in-the-making
PLease tell some one where is the fault in my code

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi.

I do not know where the problem is in your code. But I know where you can find working examples. 🙂

see org.activiti.rest.service.api.repository.DeploymentResourceTest in activiti source.

Regards
Martin

Thanks martin for your kind help.I got the working example and it is really helpful.But i am wondering here because i have done many operations using the same code only which i have posted in my question.But it is not working for deployment.Can you give any suggestion regarding this.Thanks again for you reply