cancel
Showing results for 
Search instead for 
Did you mean: 

UpLoad or deploy new workflow through Rest API

suresh72
Champ in-the-making
Champ in-the-making
Hi,

i am trying to deploy new workflow using post deployment Activiti Rest API( http://localhost:8080/activiti-rest/service/deployment) and i am getting "the request was rejected because no multipart boundary was found" Error.

Please suggest me how we can deploy new workflow through Activiti Rest API.

If possible provide me some sample Program.

regards,
suresh
3 REPLIES 3

trademak
Star Contributor
Star Contributor
Hi,

You have to post a multipart form data message to the REST service.
For example using Apache FileUpload.

Best regards,

suresh72
Champ in-the-making
Champ in-the-making
Hi,
thank you for providing information and i tried with Multipart Form data message and i got null pointer exception in server.

Please suggest me on this. I used below code.If possible provide me sample code.

regards,
suresh

public static void main(String[] args) throws IllegalStateException, IOException {
  // TODO Auto-generated method stub
 
  DefaultHttpClient dhc = new DefaultHttpClient();

  dhc.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM), new UsernamePasswordCredentials("kermit", "kermit"));

  HttpPost hp = new HttpPost("http://localhost:8080/activiti-rest/service/deployment");
  
   
  hp.addHeader( "Content-Type", "multipart/form-data; boundary=—————————28617237579832" );
  // Create AuthCache instance
  AuthCache authCache = new BasicAuthCache();
  // Generate BASIC scheme object and add it to the local auth cache
  BasicScheme basicAuth = new BasicScheme();
  authCache.put(new HttpHost("localhost", 8080, "http"), basicAuth);

  // Add AuthCache to the execution context
  BasicHttpContext localcontext = new BasicHttpContext();
  localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);
 
  MultipartEntity se = new MultipartEntity();
  File file = new File("E:/mule/DistributeWorkflow/src/test/resources/demotest.bpmn20.xml");
  se.addPart("success", new StringBody("success", Charset.forName("UTF-8")));
  se.addPart("failure", new StringBody("failure", Charset.forName("UTF-8")));
  FileBody fileBody = new FileBody(file);
  se.addPart("deployment", fileBody);
 
  hp.setEntity(se);

  HttpResponse processResponse = dhc.execute(hp,localcontext);
 
  String data=IOUtils.toString(processResponse.getEntity().getContent());
  System.out.println("reader"+data);
      
  dhc.getConnectionManager().shutdown();

}

Error:
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
        at org.activiti.rest.api.repository.DeploymentUploadResource.uploadDeployment(Deploymen
tUploadResource.java:54)
        … 58 more
Mar 6, 2012 4:26:01 PM org.restlet.engine.log.LogFilter afterHandle

suresh72
Champ in-the-making
Champ in-the-making
Hi,

My problem was solved by commenting
hp.addHeader( "Content-Type", "multipart/form-data; boundary=—————————28617237579832" );
in the above code and now i am able to deploy/upload new workflow.

Thanks and regards,
suresh