Get html of form of a task via API

1
0
-1

Hi everyone,

I have a human task to which I defined a form through the editor. Is there a way to obtain the html code of such form via the REST API?

Edit: I tried 3 different ways to get the html form throught the API:

  • /portal/form/taskInstance/taskId
  • /portal/form/processInstance/processId/task/taskName
  • /portal/homepage#?_p=tasklistinguser&_pf=1

I perform the requests after succesfully login through the API, but the first two requests still return the login form. On the other hand the third one seems to return the proper page but the body tag is empty (I imagine the content and the html of the page being generated by various scripts that are not triggered somehow). I also tried to modify the url with various parameters as explained here, but I got nowhere (I think those are not supported anymore in new version of Bonita). What am I doing wrong?

Thanks in advance.

Best

1 answer

1
0
-1

Human task form HTML content is not available using a REST API of Bonita Engine. But it is available using a Bonita Portal URL. URL has the following pattern:

http://localhost:8080/bonita/portal/resource/taskInstance/[process name]/[process version]/[step name]/content/?id=[step instance id]

For example: http://localhost:8080/bonita/portal/resource/taskInstance/GetFormREST/1....

A documentation page Bonita covers the various Bonita Portal URLs.

Comments

Submitted by Dibyajit.Roy on Thu, 02/14/2019 - 11:49

Hello
I had a Similar situation a while ago. This is how i solved it.
1) Define a Document in your Process.

2) Setup a service task. In the Service task Operation , using BDM object fetch all the Database fields

3) Create a HTML document. Format the HTML to look exactly like the User Form.
4)Insert the BDM values in the HTML document at respective Places.
5) Send the Document as Attachment over email. Reviewers can now download and view the form in HTML format.
6) You can also use the same to save the data as csv values.

7) using connectors wecan convert the HTML to PDF if Required.

Regards

Submitted by vitiellom on Wed, 02/20/2019 - 16:56

Hi and thanks for the answer. Indeed I misswrote; when I said "I tried with the API" I meant "I tried with the Portal URL". After succesffuly login through the API I tried to get the html of the page through a curl request using the URL has explained in the link above. I tried all possible URL (short and long) but got nowhere. My requests looks as follow:

# complete URL
curl -v --location-trusted -i -b saved_cookies.txt --url 'http://localhost:63717/bonita/portal/resource/taskInstance/'"$pName"'/'"$pVer"'/Task/content/?id='"$tId"'' --header "Content-Type: text/html; charset=utf-8" --header 'X-Bonita-API-Token: '"$sId"'' > "test3.html"

# short url
curl -v --location-trusted -i -b saved_cookies.txt --url 'http://localhost:63717/bonita/portal/form/taskInstance/'"$tId"'' --header "Content-Type: text/html; charset=utf-8" --header 'X-Bonita-API-Token: '"$sId"'' > "test1.html"

# alternative request
curl -v --location-trusted -i -b saved_cookies.txt --url ' http://localhost:63717/bonita/portal/form/processInstance/'"$pId"'/task/'"$tName"'' --header "Content-Type: text/html; charset=utf-8" --header 'X-Bonita-API-Token: '"$sId"'' > "test2.html"

Where:
tId: task Id;
tName: task name;
pId: process id;
pVer: process version;
pId: process id;
sId: bonita session id;

The first request return the html but the body is empty. The second one returns an nothing while with the 3rd one I get a 404 error.

Submitted by antoine.mottier on Tue, 02/26/2019 - 11:22

Here are the call I did using curl to login and get a step instance associated form:

  • curl -v -c saved_cookies.txt -X POST --url 'http://localhost:8080/bonita/loginservice' --header 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' -O /dev/null -d 'username=walter.bates&password=bpm&redirect=false&redirectURL='
    • -v: for verbose
    • -c saved_cookies.txt: to save the content of the received cookie in a file
    • -X POST: to send a POST request instead of the default GET
    • --url 'http://localhost:8080/bonita/loginservice': to call the Bonita login service
    • --header 'Content-Type: application/x-www-form-urlencoded; charset=utf-8': specified the content type required by the login service
    • -O /dev/null: redirect the result of this call to /dev/null (ignore the answer)
    • -d 'username=walter.bates&password=bpm&redirect=false&redirectURL=': define the data to send: username and password for authentication. Redirect information are only useful when user logged in using Bonita Portal login page.
    • You can find all those information on this documentation page: https://documentation.bonitasoft.com/bonita/7.8/rest-api-overview
  • curl -b saved_cookies.txt -v -X GET --url 'http://localhost:8080/bonita/portal/resource/taskInstance/GetFormREST/1....\?id\=20002'

Maybe your call failed due to an incorrect value for $sId. X-Bonita-API-Token header is not needed as you pass all the cookies information.

Notifications