title: Are there Java classes for Camunda Rest responses?
body: <p>Im currently trying to set up REST calls from Spring to my local camunda instance using the camunda rest api.</p>
  
  <p>Here's how i've set it up:</p>
  
  <ol>
  <li><p>Started a local camunda docker container on my <code>localhost:8080</code> like this: <a href="https://hub.docker.com/r/camunda/camunda-bpm-platform" rel="nofollow noreferrer">https://hub.docker.com/r/camunda/camunda-bpm-platform</a>
  (i've tested calls with postman and they are working)</p></li>
  <li><p>Built a maven project using a couple of camunda and rest dependencies in my <code>pom.xml</code>:</p></li>
  </ol>
  
  <pre class="lang-xml prettyprint-override"><code>        &lt;dependency&gt;
              &lt;groupId&gt;org.camunda.bpm.springboot&lt;/groupId&gt;
              &lt;artifactId&gt;camunda-bpm-spring-boot-starter&lt;/artifactId&gt;
              &lt;version&gt;3.3.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.camunda.bpm&lt;/groupId&gt;
              &lt;artifactId&gt;camunda-engine-rest-core&lt;/artifactId&gt;
              &lt;version&gt;7.11.0&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-webflux&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.projectreactor&lt;/groupId&gt;
              &lt;artifactId&gt;reactor-spring&lt;/artifactId&gt;
              &lt;version&gt;1.0.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <ol start="3">
  <li>Wrote a simple service to make rest calls from Spring (taken from <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-webclient" rel="nofollow noreferrer">https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-webclient</a>):</li>
  </ol>
  
  <pre class="lang-java prettyprint-override"><code>import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity;
  import org.springframework.http.HttpStatus;
  import org.springframework.stereotype.Service;
  import org.springframework.web.reactive.function.client.WebClient;
  import reactor.core.publisher.Mono;
  
  @Service
  public class MyExampleService {
  
      private final WebClient webClient;
  
      public MyExampleService (WebClient.Builder webClientBuilder) {
          this.webClient = webClientBuilder.baseUrl("http://localhost:8080").build();
      }
  
      @Override
      public ProcessDefinitionEntity[] getCamundaProcesses() {
  
          ProcessDefinitionEntity[] myResponse = this.webClient.get().uri("/engine-rest/process-definition/")
                  .retrieve()
                  .onStatus(HttpStatus::is4xxClientError, response -&gt; {
                      System.out.println("4xx eror");
                      return Mono.error(new RuntimeException("4xx"));
                  })
                  .onStatus(HttpStatus::is5xxServerError, response -&gt; {
                      System.out.println("5xx eror");
                      return Mono.error(new RuntimeException("5xx"));
                  })
                  .bodyToMono(ProcessDefinitionEntity[].class)
                  .block();
  
          return myResponse;
  }
  </code></pre>
  
  <p>So I basically used Spring WebClient to make a rest call to <code>localhost:8080/engine-rest/deployment/</code> which should give me a list of all processes as JSON (according to <a href="https://docs.camunda.org/manual/latest/reference/rest/deployment/get-query/" rel="nofollow noreferrer">https://docs.camunda.org/manual/latest/reference/rest/deployment/get-query/</a>).</p>
  
  <p>Now when I convert the response directly into a ProcessDefinitionEntity[] it won't cast the JSON into it. I also tried other classes from the camunda Java API (<a href="https://docs.camunda.org/javadoc/camunda-bpm-platform/7.11/" rel="nofollow noreferrer">https://docs.camunda.org/javadoc/camunda-bpm-platform/7.11/</a>) like <code>ProcessDefinitionDto</code>.</p>
  
  <p>None of the classes seem to properly fit the response I get from camunda. The response looks like this:</p>
  
  <pre><code>[
      {
          "id": "invoice:1:cdbc3f02-e6a1-11e9-8de8-0242ac110002",
          "key": "invoice",
          "category": "http://www.omg.org/spec/BPMN/20100524/MODEL",
          "description": null,
          "name": "Invoice Receipt",
          "version": 1,
          "resource": "invoice.v1.bpmn",
          "deploymentId": "cda115de-e6a1-11e9-8de8-0242ac110002",
          "diagram": null,
          "suspended": false,
          "tenantId": null,
          "versionTag": "V1.0",
          "historyTimeToLive": 30,
          "startableInTasklist": true
      },
      {
          "id": "invoice:2:ce03f66c-e6a1-11e9-8de8-0242ac110002",
          "key": "invoice",
          "category": "http://www.omg.org/spec/BPMN/20100524/MODEL",
          "description": null,
          "name": "Invoice Receipt",
          "version": 2,
          "resource": "invoice.v2.bpmn",
          "deploymentId": "cdfbb908-e6a1-11e9-8de8-0242ac110002",
          "diagram": null,
          "suspended": false,
          "tenantId": null,
          "versionTag": "V2.0",
          "historyTimeToLive": 45,
          "startableInTasklist": true
      }
  ]
  </code></pre>
  
  <p>(which are just the two standard processes that are in the docker container)</p>
  
  <p><strong>Are there classes in the camunda java api that properly match the responses from the camunda rest api?</strong></p>
  
  <p>PS:
  The ProcessDefinitionDto that i got from the maven dependency (which lies in <code>package org.camunda.bpm.engine.rest.dto.repository.ProcessDefinitionDto</code>) looks like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class ProcessDefinitionDto {
      protected String id;
      protected String key;
      protected String category;
      protected String description;
      protected String name;
      protected int version;
      protected String resource;
      protected String deploymentId;
      protected String diagram;
      protected boolean suspended;
      protected String tenantId;
      protected String versionTag;
      protected Integer historyTimeToLive;
      protected boolean isStartableInTasklist;
  ...
  
  </code></pre>
  
  <p>And the Response that I get from my postman call to <code>http://localhost:8080/engine-rest/process-definition</code> looks like this:</p>
  
  <pre><code>[
      {
          "id": "b506eb34-e6b1-11e9-8de8-0242ac110002",
          "key": "example_workflow",
          "category": "http://bpmn.io/schema/bpmn",
          "description": null,
          "name": "Just an Example",
          "version": 1,
          "resource": "example_workflow.bpmn",
          "deploymentId": "b503b6e2-e6b1-11e9-8de8-0242ac110002",
          "diagram": null,
          "suspended": false,
          "tenantId": null,
          "versionTag": null,
          "historyTimeToLive": null,
          "startableInTasklist": true
      },
      {
          "id": "invoice:1:cdbc3f02-e6a1-11e9-8de8-0242ac110002",
          "key": "invoice",
          "category": "http://www.omg.org/spec/BPMN/20100524/MODEL",
          "description": null,
          "name": "Invoice Receipt",
          "version": 1,
          "resource": "invoice.v1.bpmn",
          "deploymentId": "cda115de-e6a1-11e9-8de8-0242ac110002",
          "diagram": null,
          "suspended": false,
          "tenantId": null,
          "versionTag": "V1.0",
          "historyTimeToLive": 30,
          "startableInTasklist": true
      },
      {
          "id": "invoice:2:ce03f66c-e6a1-11e9-8de8-0242ac110002",
          "key": "invoice",
          "category": "http://www.omg.org/spec/BPMN/20100524/MODEL",
          "description": null,
          "name": "Invoice Receipt",
          "version": 2,
          "resource": "invoice.v2.bpmn",
          "deploymentId": "cdfbb908-e6a1-11e9-8de8-0242ac110002",
          "diagram": null,
          "suspended": false,
          "tenantId": null,
          "versionTag": "V2.0",
          "historyTimeToLive": 45,
          "startableInTasklist": true
      }
  ]
  </code></pre>