How to install a Bonita Archive with the REST API

1
0
-1

Hi all

I have been able to use the REST API but I don't understand how to install a bar (or create a new process resource) from this API.

Thanks in advance for any hint about how to proceed

François

3 answers

1
0
-1

The upload requires a different authentification than the deploy but since the goal of the upload is only to install the file on the server, it is not a big deal.

installation is working well

here is the python code where cookie is the session cookie and barpaht is the file path on the server

import json
import requests

def uploadprocess(url, cookie, barpath):
    API = "/API/bpm/process"
    URL = url + API

    headers = {"Content-type": "application/json"}
    data = {"fileupload": barpath}
    jdata = json.dumps(data)
    response = requests.post(URL, cookies=cookie,headers=headers, data=jdata)
    if response.status_code != 200:
        raise Exception("HTTP STATUS: " + str(response.status_code))
    else:
        print(response)

1
0
-1

Here is the result when trying to call the processUpload

type Rapport d'exception

message
description Le serveur a rencontré une erreur interne qui l'a empêché de satisfaire la requête.

exception

java.lang.NullPointerException
    org.bonitasoft.console.common.server.servlet.TenantFileUploadServlet.defineUploadDirectoryPath(TenantFileUploadServlet.java:39)
    org.bonitasoft.console.common.server.servlet.FileUploadServlet.doPost(FileUploadServlet.java:73)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:723)

It seems that the server requires a session to be opened (this is legitimate), but this is not a REST session. It has to be a session opened by the SessionAPI and thus it requires a different authentification.

Am I right ?

1
0
-1

Hello,

here the steps to install an archive using the portal REST API

1. Upload bar file to server using the processUpload servlet

POST /portal/processUpload
Header : Content-Type multipart/form-data;
Body : mutlipart form data containing bar file binary
Response : uploaded bar file path on server

Exemple

POST http://127.0.0.1:8888/portal/processUpload
Body:

-----------------------------197984543820969667691820371327 Content-Disposition: form-data; name="name" Buy a mini extended--6.1.bar -----------------------------197984543820969667691820371327 Content-Disposition: form-data; name="file"; filename="Buy a mini extended--6.1.bar" Content-Type: application/octet-stream 
... ...
...

Response: The Response will be the Path of the uploaded File.

You can use the following HTML form to upload your file :

<form action="http://127.0.0.1:8888/portal/processUpload" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit">
</form>

2. Deploy a ".Bar" File

POST /API/bpm/process

Body :

{ "fileupload" : "uploaded_bar_file_path_on_server" }

Response : Process json representation

{
  "id":"...",
  "icon":"...",
  "displayDescription":"...",
  "deploymentDate":"...",
  "description":"...",
  "activationState":"...",
  "name":"...",
  "deployedBy":"...",
  "displayName":"...",
  "last_update_date":"...",
  "configurationState":"...",
  "version":"..."
}
Exemple

POST http://127.0.0.1:8888/API/bpm/process
Body :

{ "fileupload" : "uploaded_bar_file_path_on_server" }

Response :

{
  "id":"6793460646707297095",
  "icon":"",
  "displayDescription":"",
  "deploymentDate":"2013-10-24 12:17:12.829",
  "description":"",
  "activationState":"DISABLED",
  "name":"ACME Process",
  "deployedBy":"6",
  "displayName":"ACME Process",
  "last_update_date":"2013-10-24 12:17:13.182",
  "configurationState":"RESOLVED",
  "version":"1.0"
}

Hope this helps.
Regards,

Julien Mege

Notifications