How to get JSON data from REST Server

1
0
-1

Hi all,

I've followed this tutorial http://documentation.bonitasoft.com/getting-started-tutorial-0
and I would just to get {{userId}} and display it in a simple form but without success.

To do this, I've created a variable varTestRest with external API type and I've set in url this : http://localhost:20414/bonita/API/system/session/{{userId}}.
I've added a text widget and I've type in text propriety varTestRest.
When I run or when I click on preview, nothing is displayed...

Someone could tell me what is wrong please ?
Thanks in advance.

Comments

Submitted by big73 on Mon, 08/31/2015 - 16:48

I've solved this issue by adding in server side an Access-Control-Allow-Origin header. Now I get data from Rest server and I can to display it in text widget but I can not to do same in table.

Have you any suggestions to do this please ?

Thanks in advance.

1 answer

1
0
-1

The user_id is inside the session object. If you have followed the getting started tutorial, you already have a variable called session, which points to ../API/system/session/unusedid.
To display the userid, add a text widget and bind the text property to session.user_id.
You can also get the name of the user from the session object, by binding to session.user_name.

This will not display anything when you preview your form, because there is no session, but it should work when you run the process that displays the form.

To put the user_id in a table widget, bind the Content property to session.user_id. However, you will get a table containing a single cell, which is maybe not what you want.

Please let us know how you get on!

Notifications