1
votes

I want to start a new process instance using REST-like API.

According to jBPM Documentnation (7.5.0.Final), it's possible to use Javascript API to start a new process instance with a form.

I was able to set up a simple html page to call the jBPMFormsAPI

<head>
  <script src="js/jbpm-forms-rest-integration.js"></script>
  <script>
      var formsAPI = new jBPMFormsAPI();
  </script>
  <script>
    function showProcessForm() {
      formsAPI.showStartProcessForm(
        "http://localhost:8080/jbpm-console/",
        "test-project_1.0.0",
        "test-project.SampleProcess",
        "myform"
      );
    }
  </script>
</head>
<body>
  <input type="button" id="showformButton"
      value="Show Process Form" onclick="showProcessForm()">
  <p/>
  <div id="myform"></div>
</body>

However, I have 404 Not Found, when I press Show Process Form button - Chrome Developer Tools - Network tab has the REST call:

http://localhost:8080/jbpm-console/rest/runtime/myproject_1.0/process/myprocess/startform

Was the REST API changed and documentation isn't up to date or I did something wrong?

I know what might help. On the same environment KIE Execution server has Swagger docs:

http://localhost:8080/kie-server/docs/

Does KIE Workbench has the same documentation or how to enable that?

I thought, it should have the similar URL, but I have 404 for the the URL too:

http://localhost:8080/jbmp-console/docs/
1
have you found a solution? - NullVoxPopuli
@NullVoxPopuli yes, I have. I'll post the answer to my question - Alex Karasev

1 Answers

2
votes

My initial guess was correct - jBPM documentation was obsolete for 7.5.0.Final and the endpoint to start process from workbench is actualy jBPM 6.x way, i.e.

http://localhost:8080/jbpm-console/rest/runtime/myproject_1.0/process/myprocess/startform

no longer valid request to start a proccess.

As a proof, take a look at actual documentation now. Chapter 14. Forms was in 7.5.0.Final, but it was removed completely in 7.7.0.Final (no chapter about js/jbpm-forms-rest-integration.js anymore).

The actual way to start a process is calling KIE Server REST API:

http://localhost:8081/kie-server/docs/

For example, I use the following curl command to start a process with a sinble field named document:

curl -X POST \
  http://localhost:8081/kie-server/services/rest/server/containers/myproject_1.0/processes/process.main/instances \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
  "document":  {
    "DocumentImpl": {
      "name": "document.zip",
      "lastModified": "2018-03-28T07:55:06.922Z",
      "size": "12",
      "content": "UEsDBAoAAAAAAOh+fUwNuzSlFgAAABYAAAAIABwAZmlsZS50eHRVVAkAA/OpvFrzqbxadXgLAAEE6AMAAAToAwAAVGhpcyBpcyBvbmx5IGEgdGVzdC4KClBLAQIeAwoAAAAAAOh+fUwNuzSlFgAAABYAAAAIABgAAAAAAAEAAACkgQAAAABmaWxlLnR4dFVUBQAD86m8WnV4CwABBOgDAAAE6AMAAFBLBQYAAAAAAQABAE4AAABYAAAAAAA="
    }
  }
}'