# How to install a Bonita Archive with the REST API

**URL:** <https://community.ofelia.com/t/how-to-install-a-bonita-archive-with-the-rest-api/4028>\
**Category:** Q&A\
**Created:** [16 December 2013 20:22 UTC](https://community.ofelia.com/t/how-to-install-a-bonita-archive-with-the-rest-api/4028 "2013-12-16T20:22:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![charoy](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@charoy](https://community.ofelia.com/u/charoy)\
**Post date:** [16 December 2013 20:22 UTC](https://community.ofelia.com/t/how-to-install-a-bonita-archive-with-the-rest-api/4028/1 "2013-12-16T20:22:54Z")

</div>

Hi all

&nbsp;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

&nbsp;

François

---

<div class="post-metadata">

**Author:** ![julien.mege](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/julien.mege/32/737_2.png) [@julien.mege](https://community.ofelia.com/u/julien.mege)\
**Post date:** [20 December 2013 16:14 UTC](https://community.ofelia.com/t/how-to-install-a-bonita-archive-with-the-rest-api/4028/2 "2013-12-20T16:14:40Z")

</div>

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](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:&nbsp; The Response will be the Path of the uploaded File.

&nbsp;

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

> &lt;form action="http://127.0.0.1:8888/portal/processUpload" method="post" enctype="multipart/form-data"&gt;  
> &nbsp;&nbsp;&nbsp; &lt;input type="file" name="file"&gt;  
> &nbsp;&nbsp;&nbsp; &lt;input type="submit"&gt;  
> &lt;/form&gt;

&nbsp;

### 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](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

---

<div class="post-metadata">

**Author:** ![charoy](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@charoy](https://community.ofelia.com/u/charoy)\
**Post date:** [9 January 2014 13:37 UTC](https://community.ofelia.com/t/how-to-install-a-bonita-archive-with-the-rest-api/4028/3 "2014-01-09T13:37:48Z")

</div>

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.&nbsp;

Am I right ?

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![charoy](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@charoy](https://community.ofelia.com/u/charoy)\
**Post date:** [10 January 2014 12:54 UTC](https://community.ofelia.com/t/how-to-install-a-bonita-archive-with-the-rest-api/4028/4 "2014-01-10T12:54:40Z")

</div>

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 &nbsp;is not a big deal.

&nbsp;

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)
```
