Error while deploying using REST API

CURL Request

curl -X POST \
  http://localhost:8080/rest/deployment/create \
  -H 'cache-control: no-cache' \
  -H 'content-type: multipart/form-data; boundary=--28319d96a8c54b529aa9159ad75edef9' \
  -H 'postman-token: b83aed9a-cc65-a25d-93d6-472f748a37b3' \
  -d '--28319d96a8c54b529aa9159ad75edef9
Content-Disposition: form-data; name="deployment-name"

temp-bpmn-1
--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:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.0">
  <bpmn:process id="Process_1" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>SequenceFlow_1f072ei</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="SequenceFlow_1f072ei" sourceRef="StartEvent_1" targetRef="Task_0qgb9mm" />
    <bpmn:userTask id="Task_0qgb9mm">
      <bpmn:extensionElements>
        <camunda:formData>
          <camunda:formField id="FormField_0of6ete" label="Were you an idiot before?" type="boolean" />
        </camunda:formData>
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow_1f072ei</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_02hdm53</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:endEvent id="EndEvent_0s66wq0">
      <bpmn:incoming>SequenceFlow_02hdm53</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="SequenceFlow_02hdm53" sourceRef="Task_0qgb9mm" targetRef="EndEvent_0s66wq0" />
  </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="172" y="198" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="145" y="234" width="90" height="20" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1f072ei_di" bpmnElement="SequenceFlow_1f072ei">
        <di:waypoint xsi:type="dc:Point" x="208" y="216" />
        <di:waypoint xsi:type="dc:Point" x="281" y="216" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="244.5" y="194.5" width="0" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="UserTask_0fc8fbx_di" bpmnElement="Task_0qgb9mm">
        <dc:Bounds x="281" y="176" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_0s66wq0_di" bpmnElement="EndEvent_0s66wq0">
        <dc:Bounds x="438" y="198" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="456" y="237" width="0" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_02hdm53_di" bpmnElement="SequenceFlow_02hdm53">
        <di:waypoint xsi:type="dc:Point" x="381" y="216" />
        <di:waypoint xsi:type="dc:Point" x="438" y="216" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="409.5" y="194" width="0" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
--28319d96a8c54b529aa9159ad75edef9--'

HTTP Response

{
    "type": "InvalidRequestException",
    "message": "No deployment resources contained in the form upload."
}

Java Error StackTrace

WARN 6628 --- [nio-8080-exec-4] ExceptionHandler                         : org.camunda.bpm.engine.rest.exception.InvalidRequestException: No deployment resources contained in the form upload.
	at org.camunda.bpm.engine.rest.impl.DeploymentRestServiceImpl.createDeployment(DeploymentRestServiceImpl.java:154)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:205)
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
	at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.camunda.bpm.webapp.impl.security.filter.SecurityFilter.doFilterSecure(SecurityFilter.java:67)
	at org.camunda.bpm.webapp.impl.security.filter.SecurityFilter.doFilter(SecurityFilter.java:51)
	at org.camunda.bpm.spring.boot.starter.webapp.filter.LazyDelegateFilter.doFilter(LazyDelegateFilter.java:44)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter$1.execute(AuthenticationFilter.java:59)
	at org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter$1.execute(AuthenticationFilter.java:56)
	at org.camunda.bpm.webapp.impl.security.SecurityActions.runWithAuthentications(SecurityActions.java:38)
	at org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter.doFilter(AuthenticationFilter.java:56)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	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)

What am I missing? :roll_eyes:

POST /engine-rest/deployment/create HTTP/1.1
Host: localhost:1234
Accept: application/json
Cache-Control: no-cache
Postman-Token: 5ea4d6fc-f9ab-5292-1065-934c2228a5a0
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="deployment-name"

My Deployment
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="enable-duplicate-filtering"

false
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="deploy-changed-only"

false
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="deployment-source"

local
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="tenant-id"

My Tenant
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="MyBPMNFileName.bpmn"; filename=""
Content-Type: 


------WebKitFormBoundary7MA4YWxkTrZu0gW--

Ignore the cookies part.

Is this section right? I wanted to embed the file content here directly. There is no file from which I can read the xml.

For the above request I get error

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

How to make this work?

Can you send a screenshot of your postman setup.
Can you try with the raw curl in terminal.

Not sure about what content type I should mention in the last multipart form

Content-Disposition: form-data; name=“MyBPMNFileName.bpmn”
Content-Type:

In the example provided in camunda docs there is no content type (Post Deployment | docs.camunda.org). I tried application/octet-stream and application/xml but didn’t work.

I did make this work from postman using form-data option by selecting the local file but I wanted to use this rest api just with the file content rather than a saved file

Screenshot Request Body and Response

Screenshot header

CURL (Generated from postman code itself)

curl -X POST \
  http://localhost:8080/rest/deployment/create \
  -H 'cache-control: no-cache' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -H 'postman-token: 545f0c09-f8ad-2835-6f47-6ce1c82ddd2c' \
  -d '------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="deployment-name"

My Deployment
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="enable-duplicate-filtering"

false
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="deploy-changed-only"

false
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="deployment-source"

local
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="tenant-id"

My Tenant
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="MyBPMNFileName.bpmn"
Content-Type:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.0">
  <bpmn:process id="Process_1" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>SequenceFlow_1f072ei</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="SequenceFlow_1f072ei" sourceRef="StartEvent_1" targetRef="Task_0qgb9mm" />
    <bpmn:userTask id="Task_0qgb9mm">
      <bpmn:extensionElements>
        <camunda:formData>
          <camunda:formField id="FormField_0of6ete" label="Were you an idiot before?" type="boolean" />
        </camunda:formData>
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow_1f072ei</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_02hdm53</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:endEvent id="EndEvent_0s66wq0">
      <bpmn:incoming>SequenceFlow_02hdm53</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="SequenceFlow_02hdm53" sourceRef="Task_0qgb9mm" targetRef="EndEvent_0s66wq0" />
  </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="172" y="198" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="145" y="234" width="90" height="20" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1f072ei_di" bpmnElement="SequenceFlow_1f072ei">
        <di:waypoint xsi:type="dc:Point" x="208" y="216" />
        <di:waypoint xsi:type="dc:Point" x="281" y="216" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="244.5" y="194.5" width="0" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="UserTask_0fc8fbx_di" bpmnElement="Task_0qgb9mm">
        <dc:Bounds x="281" y="176" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_0s66wq0_di" bpmnElement="EndEvent_0s66wq0">
        <dc:Bounds x="438" y="198" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="456" y="237" width="0" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_02hdm53_di" bpmnElement="SequenceFlow_02hdm53">
        <di:waypoint xsi:type="dc:Point" x="381" y="216" />
        <di:waypoint xsi:type="dc:Point" x="438" y="216" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="409.5" y="194" width="0" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
------WebKitFormBoundary7MA4YWxkTrZu0gW--'

48 PM

Your post man should look like this. And make sure to select your bpmn file in the last row.

As I mentioned already in my previous reply that I did made this work using form data option in postman. What I was looking for is a way to use this rest api without having a file but just with the bpmn xml content. Postman or javascript is not an option may be for my use case. I will send the XML to the backend which in turn deploy the xml using java API. Hope it works.

Thanks a lot @StephenOTT

@pradeep take a look at: https://github.com/StephenOTT/ProcessProjectTemplate

There is a jenkins file that does a deployment for you when you commit the repo that holds the bpmn and related files. all controlled through the [env]_deploy.json files.

May be of more interest for you if you are looking to deploy the xml. You can commit to a GIT repo (for version control) and have to deploy to your camunda server.

Hi, I new and I’m practicing whith Learn Camunda with Nial (Camunda Rest API Tutorial). I had the same error. My fault it was that key and value were in different places and there haven’t been in the same line.

Hi @RodrigoPLpz,

Deploying a bpmn file via REST API with Postman worked so very well for me:

grafik

Make the following key/value entry in the "Headers" tab:

  • Key: “Content-Type”
  • Value: “multipart/form-data”

Result:
200 OK

{
    "links": [
        {
            "method": "GET",
            "href": "http://localhost:8080/engine-rest/deployment/cf04d2b3-13ed-11ed-96d2-484520c99621",
            "rel": "self"
        }
    ],
    "id": "cf04d2b3-13ed-11ed-96d2-484520c99621",
    "name": "Hello World",
    "source": null,
    "deploymentTime": "2022-08-04T14:06:01.972+0200",
    "tenantId": null,
    "deployedProcessDefinitions": {
        "Process_HelloWorld:3:cf31d625-13ed-11ed-96d2-484520c99621": {
            "id": "Process_HelloWorld:3:cf31d625-13ed-11ed-96d2-484520c99621",
            "key": "Process_HelloWorld",
            "category": "http://bpmn.io/schema/bpmn",
            "description": null,
            "name": "Hello World Process",
            "version": 3,
            "resource": "helloWorld5.bpmn",
            "deploymentId": "cf04d2b3-13ed-11ed-96d2-484520c99621",
            "diagram": null,
            "suspended": false,
            "tenantId": null,
            "versionTag": null,
            "historyTimeToLive": null,
            "startableInTasklist": true
        }
    },
    "deployedCaseDefinitions": null,
    "deployedDecisionDefinitions": null,
    "deployedDecisionRequirementsDefinitions": null
}

I hope this helps you move forward.

Hi all,

in an “integration component” (based on Spring Boot and Apache Camel) I am trying to implement a route for a deployment of a BPMN process definition (bpmn file). The special characteristic is that for the deployment a multipart form has to be created.

I have already deployed the used BPMN file using Postman in Camunda via REST API. There the deployment was successful.

Unfortunately the deployment in my Camel integration component is not successful. I get the following message from Camel (incl. stacktrace) when trying to execute the http request:

=> Do you know any advice?

2022-08-04 13:26:26.097  INFO 11748 --- [a/bpmn-stateful] route1                                   : POST helloWorld5.bpmn to 'Create Deployment'
2022-08-04 13:26:26.102 ERROR 11748 --- [a/bpmn-stateful] o.a.camel.processor.DefaultErrorHandler  : Failed delivery for (MessageId: LAPTOP-0-67 on ExchangeId: LAPTOP-0-67). Exhausted after delivery attempt: 1 caught: org.apache.camel.http.common.HttpOperationFailedException: HTTP operation failed invoking http://127.0.0.1:8080/engine-rest/deployment/create with statusCode: 400

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
[route1            ] [route1            ] [file://target/data/bpmn-stateful?noop=true                                    ] [         6]
[route1            ] [process1          ] [Processor@0x4c947a0                                                           ] [         0]
[route1            ] [log1              ] [log                                                                           ] [         1]
[route1            ] [log2              ] [log                                                                           ] [         0]
[route1            ] [setHeader1        ] [setHeader[CamelHttpMethod]                                                    ] [         0]
[route1            ] [log3              ] [log                                                                           ] [         0]
[route1            ] [to1               ] [http://127.0.0.1:8080/engine-rest/deployment/create                           ] [         4]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------

org.apache.camel.http.common.HttpOperationFailedException: HTTP operation failed invoking http://127.0.0.1:8080/engine-rest/deployment/create with statusCode: 400
	at org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:273) ~[camel-http-2.25.4.jar:2.25.4]
	at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:182) ~[camel-http-2.25.4.jar:2.25.4]
	at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) ~[camel-core-2.25.4.jar:2.25.4]
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148) ~[camel-core-2.25.4.jar:2.25.4]
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) ~[camel-core-2.25.4.jar:2.25.4]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) ~[camel-core-2.25.4.jar:2.25.4]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:138) ~[camel-core-2.25.4.jar:2.25.4]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:101) ~[camel-core-2.25.4.jar:2.25.4]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) ~[camel-core-2.25.4.jar:2.25.4]
	at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:452) ~[camel-core-2.25.4.jar:2.25.4]
	at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:221) ~[camel-core-2.25.4.jar:2.25.4]
	at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:185) ~[camel-core-2.25.4.jar:2.25.4]
	at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174) ~[camel-core-2.25.4.jar:2.25.4]
	at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101) ~[camel-core-2.25.4.jar:2.25.4]
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
	at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[na:na]
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
	at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]

My setup:

  • Camunda Platform v7.16 (as standalone engine)
  • Open JDK 11
  • Apache Camel v2.25.4
  • “Integration Component” (Maven Project/Spring Boot/Apache Camel)

Route:

@Override
	public void configure() throws Exception {
		from("file:target/data/bpmn-stateful?noop=true")
		.process(new BpmnStatefulDiagramsPrepForCamDeployment())
		.log("Content Type: ${header.Content-Type}")
		.log("${body}")
		.setHeader("CamelHttpMethod",constant("POST"))
		.log("${header.CamelHttpMethod} ${header.CamelFileName} to 'Create Deployment'")
		.to(wfms_rest_api_endpoint+"/deployment/create")
		.log("HTTP response status:"+header("HTTP_RESPONSE_CODE"))
		.log(LoggingLevel.DEBUG, "HTTP response body:\n${body}");
	}

Processor “BpmnStatefulDiagramsPrepForCamDeployment”:

@Override
	public void process(Exchange exchange) throws Exception {
		
		//Determine bpmn file from Camel Exchange (Message):
		File bpmnFile = exchange.getMessage().getBody(File.class);
				
		//Encode the file and other relevant parts for Camunda Deployment as a multipart entity:
		StringBody deploymentName = new StringBody(bpmnFile.getName(), 
                                                                                             ContentType.TEXT_PLAIN);
		FileBody bpmnFileBody = new FileBody(bpmnFile,ContentType.DEFAULT_BINARY);
		StringBody enableDuplicateFiltering = new StringBody("false", ContentType.TEXT_PLAIN);
		StringBody deployChangedOnly = new StringBody("false", ContentType.TEXT_PLAIN);
		
		MultipartEntityBuilder entity = MultipartEntityBuilder.create()
		  .addPart("deployment-name",deploymentName)
		  .addPart("enable-duplicate-filtering", enableDuplicateFiltering)
	         .addPart("deploy-changed-only", deployChangedOnly)
	         .addPart("data",bpmnFileBody);
		 
		HttpEntity httpEntity = entity.build();
				
	   // Set multipart entity as the message’s body:	
	    exchange.getMessage().setHeader(Exchange.CONTENT_TYPE, 
                                                                    httpEntity.getContentType().getValue());
		exchange.getMessage().setBody(httpEntity.getContent());
				
	}

This is what the generated Camel body looks like (log output):

2022-08-04 13:26:26.096  INFO 11748 --- [a/bpmn-stateful] route1                                   : Content Type: multipart/form-data; boundary=93V2QBikaz4TbAtEtPj1BCJ5sfcHB7wvP0v0C
2022-08-04 13:26:26.097  INFO 11748 --- [a/bpmn-stateful] route1                                   : --93V2QBikaz4TbAtEtPj1BCJ5sfcHB7wvP0v0C
Content-Disposition: form-data; name="deployment-name"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

helloWorld5.bpmn
--93V2QBikaz4TbAtEtPj1BCJ5sfcHB7wvP0v0C
Content-Disposition: form-data; name="enable-duplicate-filtering"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

false
--93V2QBikaz4TbAtEtPj1BCJ5sfcHB7wvP0v0C
Content-Disposition: form-data; name="deploy-changed-only"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

false
--93V2QBikaz4TbAtEtPj1BCJ5sfcHB7wvP0v0C
Content-Disposition: form-data; name="data"; filename="helloWorld5.bpmn"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1i0cf2y" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.4.0">
  <bpmn:process id="Process_HelloWorld" name="Hello World Process" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1" name="YYY">
      <bpmn:outgoing>Flow_03cn8wt</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:userTask id="Activity_0jx573r" name="Hello World">
      <bpmn:incoming>Flow_03cn8wt</bpmn:incoming>
      <bpmn:outgoing>Flow_18fgsbo</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:sequenceFlow id="Flow_03cn8wt" sourceRef="StartEvent_1" targetRef="Activity_0jx573r" />
    <bpmn:endEvent id="Event_0krdwi0">
      <bpmn:incoming>Flow_18fgsbo</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_18fgsbo" sourceRef="Activity_0jx573r" targetRef="Event_0krdwi0" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_HelloWorld">
      <bpmndi:BPMNEdge id="Flow_18fgsbo_di" bpmnElement="Flow_18fgsbo">
        <di:waypoint x="360" y="120" />
        <di:waypoint x="402" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_03cn8wt_di" bpmnElement="Flow_03cn8wt">
        <di:waypoint x="215" y="127" />
        <di:waypoint x="238" y="127" />
        <di:waypoint x="238" y="120" />
        <di:waypoint x="260" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="109" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="186" y="152" width="22" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1k0gs20_di" bpmnElement="Activity_0jx573r">
        <dc:Bounds x="260" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0krdwi0_di" bpmnElement="Event_0krdwi0">
        <dc:Bounds x="402" y="102" width="36" height="36" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

--93V2QBikaz4TbAtEtPj1BCJ5sfcHB7wvP0v0C--

I have already studied the following help pages:

Any timely advice would be greatly appreciated!

Hi @Niall,

do you know any advice regarding my post of 04.08.22 (see above)?

Many thanks for your support in advance!

Hey @LSchoenfeld,

if the REST endpoint is working, and I assume it does as you tested it with Postman, the problem is within the implementation of the REST call in your java application. Unfortunately, I am not familiar with Camel. Is there a reason why you use Camel for the Deployment? You could also deploy the diagram by using SpringBoot, for example.

Kind regards
Nele

Hi @Nele,

thank you very much for your answer.

Your assumption is correct: the REST endpoint is running.

I am using a specific architecture here. Therefore I deploy an integration process from another component to a remote application with embedded Camunda Process Engine. For integration pattern I am using Apache Camel. Deployment within the same application of process definitions is known to me, but not possible because of the particular architecture.

I suppose that the generated multipart form data is not accepted by the Camunda Engine via REST. Please have a look at this part:

Content-Disposition: form-data; name="deployment-name"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

helloWorld5.bpmn
--93V2QBikaz4TbAtEtPj1BCJ5sfcHB7wvP0v0C
Content-Disposition: form-data; name="enable-duplicate-filtering"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

false
--93V2QBikaz4TbAtEtPj1BCJ5sfcHB7wvP0v0C
Content-Disposition: form-data; name="deploy-changed-only"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

false
--93V2QBikaz4TbAtEtPj1BCJ5sfcHB7wvP0v0C
Content-Disposition: form-data; name="data"; filename="helloWorld5.bpmn"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1i0cf2y" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.4.0">
  <bpmn:process id="Process_HelloWorld" name="Hello World Process" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1" name="YYY">
      <bpmn:outgoing>Flow_03cn8wt</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:userTask id="Activity_0jx573r" name="Hello World">
      <bpmn:incoming>Flow_03cn8wt</bpmn:incoming>
      <bpmn:outgoing>Flow_18fgsbo</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:sequenceFlow id="Flow_03cn8wt" sourceRef="StartEvent_1" targetRef="Activity_0jx573r" />
    <bpmn:endEvent id="Event_0krdwi0">
      <bpmn:incoming>Flow_18fgsbo</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_18fgsbo" sourceRef="Activity_0jx573r" targetRef="Event_0krdwi0" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_HelloWorld">
      <bpmndi:BPMNEdge id="Flow_18fgsbo_di" bpmnElement="Flow_18fgsbo">
        <di:waypoint x="360" y="120" />
        <di:waypoint x="402" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_03cn8wt_di" bpmnElement="Flow_03cn8wt">
        <di:waypoint x="215" y="127" />
        <di:waypoint x="238" y="127" />
        <di:waypoint x="238" y="120" />
        <di:waypoint x="260" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="109" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="186" y="152" width="22" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1k0gs20_di" bpmnElement="Activity_0jx573r">
        <dc:Bounds x="260" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0krdwi0_di" bpmnElement="Event_0krdwi0">
        <dc:Bounds x="402" y="102" width="36" height="36" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

--93V2QBikaz4TbAtEtPj1BCJ5sfcHB7wvP0v0C--

The XML part in the code excerpt above (Multipart form data) is the BPMN file for testing purposes.

Is there anything special I need to consider when passing the deployment artifact to Camunda REST API? - Or in other words: What do I need to consider when deploying via the Camunda REST API Multipart form data)?

How would you deploy processes/decisions in Java as multipart form data via Camunda REST API?

Best Regards and thanks