REST API: Post Deployment: multipart/form-data cannot be processed

1,385 views
Skip to first unread message

Max Frei

unread,
Feb 26, 2016, 9:15:16 AM2/26/16
to camunda BPM users
Hi,

I try to post a new deployment to my engine:

Adress:


Headers:

Cache-Control: no-cache
Content-Type: multipart/form-data; boundary="28319d96a8c54b529aa9159ad75edef9"

Payload:

--28319d96a8c54b529aa9159ad75edef9
Content-Disposition: form-data; name="deployment-name"

aName
--28319d96a8c54b529aa9159ad75edef9
Content-Disposition: form-data; name="enable-duplicate-filtering"

true
--28319d96a8c54b529aa9159ad75edef9
Content-Disposition: form-data; name="deployment-source"

process application
--28319d96a8c54b529aa9159ad75edef9
Content-Disposition: form-data; name="data"; filename="test.bpmn"

<?xml version="1.0" encoding="UTF-8"?>
  <bpmn:process id="Process_1" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1" name="Start">
      <bpmn:outgoing>SequenceFlow_1togjcr</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:task id="Task_1g5iddu" name="Do something">
      <bpmn:incoming>SequenceFlow_1togjcr</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_1r5vu0t</bpmn:outgoing>
    </bpmn:task>
    <bpmn:sequenceFlow id="SequenceFlow_1togjcr" sourceRef="StartEvent_1" targetRef="Task_1g5iddu" />
    <bpmn:endEvent id="EndEvent_1bhvajf" name="End">
      <bpmn:incoming>SequenceFlow_1r5vu0t</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="SequenceFlow_1r5vu0t" sourceRef="Task_1g5iddu" targetRef="EndEvent_1bhvajf" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="173" y="102" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Task_1g5iddu_di" bpmnElement="Task_1g5iddu">
        <dc:Bounds x="257" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1togjcr_di" bpmnElement="SequenceFlow_1togjcr">
        <di:waypoint xsi:type="dc:Point" x="209" y="120" />
        <di:waypoint xsi:type="dc:Point" x="257" y="120" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="171.5" y="105.5" width="90" height="20" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="EndEvent_1bhvajf_di" bpmnElement="EndEvent_1bhvajf">
        <dc:Bounds x="400" y="102" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="373" y="138" width="90" height="20" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1r5vu0t_di" bpmnElement="SequenceFlow_1r5vu0t">
        <di:waypoint xsi:type="dc:Point" x="357" y="120" />
        <di:waypoint xsi:type="dc:Point" x="400" y="120" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="333.5" y="110" width="90" height="20" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn2:definitions>
--28319d96a8c54b529aa9159ad75edef9--

I got the following error:

400: Bad Request

{
"type": "RestException"
"message": "multipart/form-data cannot be processed"
}


Log from the server:

org.camunda.bpm.engine.rest.exception.RestExceptionHandler.toResponse org.camunda.bpm.engine.rest.exception.RestException: multipart/form-data cannot be processed

Does somebody has any idea to solve that problem?

Sebastian Menski

unread,
Feb 26, 2016, 9:28:12 AM2/26/16
to camunda BPM users
Hi Max,

can you please attach the full stack trace so we can see the cause of the exception. Thanks.

Cheers,
Sebastian

Max Frei

unread,
Feb 26, 2016, 9:31:33 AM2/26/16
to camunda BPM users
Hi Sebastian,

is that enough:

26-Feb-2016 15:11:11.967 WARNING [http-nio-8080-exec-200] org.camunda.bpm.engine.rest.exception.RestExceptionHandler.toResponse org.camunda.bpm.engine.rest.exce
ption.RestException: multipart/form-data cannot be processed
        at org.camunda.bpm.engine.rest.mapper.MultipartPayloadProvider.parseRequest(MultipartPayloadProvider.java:93)
        at org.camunda.bpm.engine.rest.mapper.MultipartPayloadProvider.readFrom(MultipartPayloadProvider.java:71)
        at org.camunda.bpm.engine.rest.mapper.MultipartPayloadProvider.readFrom(MultipartPayloadProvider.java:49)
        at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:105)
        at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.read(GZIPDecodingInterceptor.java:63)
        at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:108)
        at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:169)
        at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:136)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:159)
        at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257)
        at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222)
        at org.jboss.resteasy.core.ResourceLocator.invokeOnTargetObject(ResourceLocator.java:159)
        at org.jboss.resteasy.core.ResourceLocator.invoke(ResourceLocator.java:92)
        at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
        at org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:169)
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:212)
        at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:59)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.camunda.bpm.engine.rest.filter.CacheControlFilter.doFilter(CacheControlFilter.java:41)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
        at org.apache.commons.fileupload.MultipartStream.readHeaders(MultipartStream.java:538)
        at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.findNextItem(FileUploadBase.java:999)
        at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:965)
        at org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:331)
        at org.camunda.bpm.engine.rest.mapper.MultipartPayloadProvider.parseRequest(MultipartPayloadProvider.java:87)
        ... 38 more

Best Regards,
Max

Sebastian Menski

unread,
Feb 27, 2016, 4:13:50 AM2/27/16
to camunda BPM users
Hi Max,

how did you create this request? It seems that there is a problem with the line endings so the multipart form data parser cannot detect the end of the request. The line
endings should be CRLF (\r\n).

If I convert the line endings of your request body to CRLF I can successfully create the deployment. Or rather get a parser exception as your BPMN XML isn't valid.
The root element <bpmn2:definitions uses an unspecified namespace prefix. The BPMN namespace is bound to bpmn in your XML, so it should be <bpmn:definitions.

Cheers,
Sebastian

Max Frei

unread,
Feb 27, 2016, 2:15:41 PM2/27/16
to camunda BPM users
Hi Sebastian,

thanks for you help. Unfortunately I can't perform the post. I did try it with the Google Chrome Plugin Advanced Rest Client:


I checked the file. It encoded in UTF-8 and the end of the lines is set with CRLF:



 I tried it with Java as I did with the Rest Client. Same same. I added the whole request as a file. Now I'm using the prefix <bpmn:definitions

By the way: I'm using the latest stable release camunda 7.4.

Best regards and thanks in advance for your help.

Max

Max Frei

unread,
Feb 27, 2016, 2:22:19 PM2/27/16
to camunda BPM users
Now the file with the request body...
post.txt

Sebastian Menski

unread,
Feb 28, 2016, 7:51:26 AM2/28/16
to camunda BPM users
Hi Max,

I'm not sure if you can use the Advanced Rest Client do manually write the multipart request body. It seems that the client is then sending an malformed request. If you want to
use the Advanced Rest Client please the forms and files payload fields:



Your post.txt payload is correct. I can use curl to successfully deploy it:

curl -v -H 'Content-Type: multipart/form-data; boundary=28319d96a8c54b529aa9159ad75edef9' --data-binary "@post.txt" localhost:8080/engine-rest/deployment/create

For an example how to deploy through the REST API with Java code please see this example:

Cheers,
Sebastian

Max Frei

unread,
Feb 28, 2016, 2:07:40 PM2/28/16
to camunda BPM users
Hello Sebastian,

I did like you said und like in the example. Now it works with the Chrome Plugin as well as with the Java Code.

Thank you so much for your qualified help!

Max
Reply all
Reply to author
Forward
0 new messages