UpLoad or deploy new workflow through Rest API

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2012 10:04 AM
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
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
Labels:
- Labels:
-
Archive
3 REPLIES 3

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2012 01:34 PM
Hi,
You have to post a multipart form data message to the REST service.
For example using Apache FileUpload.
Best regards,
You have to post a multipart form data message to the REST service.
For example using Apache FileUpload.
Best regards,

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2012 06:10 AM
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
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

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2012 06:31 AM
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
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
