Add document (Rest API)

1
0
-1

Hello,

I' m trying to upload files with bonita rest API and I had two problems:

  1. To test rest Api, in chrome I make login in bonita portal, and created a case. In the same browser i open a new tab and in postman extension I build a request like this

url = http://localhost:8080/bonita/API/bpm/caseDocument:

data = {"caseId":"29","file":"C:\flexitex2.jpg","name":"flexitex2","description":"draft"} where my case id was = 29.

The server send back that response

{ "id": "3", "creationDate": "2015-01-14 14:42:16.237", "author": "25", "index": "-1", "contentMimetype": "", "caseId": "29", "description": "draft", "name": "flexitex2", "fileName": "", "isInternal": "true", "submittedBy": "25", "url": "documentDownload?fileName=null&contentStorageId=3", "contentStorageId": "3", "version": "1" }

The attr content type and fileName is empty. What I am doing wrong here?

  1. In widget html in one form I have this script

$.post( "http://localhost:8080/bonita/API/bpm/caseDocument", JSON.stringify( {"caseId": caseId, "file": "C:\flexitex1.PNG", "name": "flexitex1", "description": "draft"}), });

this scripts runs when i click in one specific button. The server send back this response was:

exception: "class java.lang.NullPointerException" message: "" stacktrace: ["org.bonitasoft.web.toolkit.client.common.json.JSonItemReader.parseItem(JSonItemReader.java:212)",…] 0: "org.bonitasoft.web.toolkit.client.common.json.JSonItemReader.parseItem(JSonItemReader.java:212)" 1: "org.bonitasoft.web.toolkit.client.common.json.JSonItemReader.parseItem(JSonItemReader.java:198)" 2: "org.bonitasoft.web.toolkit.client.common.json.JSonItemReader.parseItem(JSonItemReader.java:188)" 3: "org.bonitasoft.web.toolkit.client.common.json.JSonItemReader.parseItem(JSonItemReader.java:168)" 4: "org.bonitasoft.web.rest.server.framework.APIServletCall.getJSonStreamAsItem(APIServletCall.java:129)"

What I am doing wrong in this script?

Can anyone help me with this call?

Thanks in advance and sorry for my english.

2 answers

1
+1
-1
This one is the BEST answer!

I think it should be possible to achieve your use case by doing to separated call to the API:

Comments

Submitted by jarg on Mon, 01/19/2015 - 13:54

Thanks for your answers,

I resolved the problem. My intention was develop in bonita form a user interface to upload multiple files. So, I created two types of interfaces (for test). In first interface it is possible to user attach one file for task, and interface show all filles of the process. I do this because, if we submitted a task with a file and the process return to this task again and user need to attach another file without override the first file, he can´t. In second interface the user can add multiple file to a task but for that, he have to put the full file path to upload the file in one textField. It works, but i have to do better, I am not satisfied for the second solution.

Submitted by philippe.ozil on Mon, 01/19/2015 - 14:34

Hello,

FYI, uploading multiple files within a single form can be achieved using the "Dynamic Web forms designer" feature that is part of the Subscription editions: http://www.bonitasoft.com/how-we-do-it/compare-editions

Cheers,

Submitted by stalinramirez on Thu, 04/23/2015 - 05:35

Hola Jarg Estoy en un problema similar de adjuntar varios archivos podrias ayudarme??

1
0
-1

Hello

In fact, the engine constructor allowed it in 6.4, but it was fixed in 6.4.2 it is not allowed to create a case document with a content and no filename. because we are not able generate a correct filename to access it in the document download servlet.

I hope this information help you

Nicolas

Notifications