Rest API Call

1
0
-1

Hi,

I am newbie using Bonita platform. Just created a process flow that connects to database and web service.

I am trying to get some examples/samples to call external rest API using rest connectors from a process flow. Also looking at samples that show how can we call the process in bpm using rest api.

Can somebody help with this request?

Thanks in advance.

Pooja

Comments

Submitted by antoine.mottier on Wed, 07/10/2019 - 14:27

About the usage of REST API, do you want to process the result of the API call as part of the process (e.g. send an email with the response data, generate a document using the response data...) or do you want to display it to the user in a form (read-only)?

I'm asking because the solution would be different: for the first one you probably want to use a REST connector and store the result in a business variable, for the second you probably want to use a form variable initialized directly with the REST API call. In the first solution the REST API call will be performed by Bonita Engine who will run the process, in the second situation it will be performed by the user web browser who load the form.

Submitted by pooja.lnu_1403454 on Wed, 07/10/2019 - 14:34

I want to test it both ways. I figured the 2 things last evening going over the documentation and the forum. I need some help processing the response data. I am storing the result as bodyAsObject but dont know how to get the result from it. I have understood it needs to be done in the script but dont know the syntax. Can you point to some sample code on how to extract data from bodyAsObject or set values for json object for PUT. Thanks again for responding.

Submitted by antoine.mottier on Wed, 07/10/2019 - 19:07

I just published a new example to illustrate the first option. It is available from the following GitHub repository: https://github.com/Bonitasoft-Community/rest-connector-to-business-data

Submitted by pooja.lnu_1403454 on Thu, 07/11/2019 - 03:45

Hi Antoine, the .bos file is not importing into Bonita studio. Getting the below error:

!ENTRY org.bonitasoft.studio.ui 4 0 2019-07-10 20:39:50.592
!MESSAGE
!STACK 0
java.lang.IllegalArgumentException:
at org.bonitasoft.studio.importer.bos.model.BosArchive.toImportModel(BosArchive.java:66)
at org.bonitasoft.studio.importer.bos.operation.ImportConflictsChecker.checkConflicts(ImportConflictsChecker.java:43)
at org.bonitasoft.studio.importer.bos.operation.ParseBosArchiveOperation.run(ParseBosArchiveOperation.java:42)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)

Thanks,
Pooja

Submitted by pooja.lnu_1403454 on Fri, 07/12/2019 - 02:01

Hi Antoine, I installed v7.9.1 and imported the .bos file and its working. Sorry never noticed that you created that on a newer version. Your sample is really helpful for get me started.

Thanks,
Pooja

Submitted by antoine.mottier on Wed, 07/17/2019 - 12:22

Hi Pooja, I just published a second example that illustrate how you can directly within a Bonita web form call a REST API.

2 answers

1
0
-1

I can return single values like integers or strings but I can't return more complex objects, containing other objects and lists, to the BDM.

Let's say I consume this:

https://www.metaweather.com/api/location/44418/

How can I map the output to a BDM object with same structure?

1
0
-1

hi Pooja,

I hope if you use the API Rest Extension Context (https://community.bonitasoft.com/project/restapicontext) it will help you.

regards
Kaant

Comments

Submitted by pooja.lnu_1403454 on Wed, 07/10/2019 - 20:18

Thanks a lot. Let me look at the documentation.

Submitted by pooja.lnu_1403454 on Thu, 07/11/2019 - 04:15

Hey Kaant,

I tried the steps and while importing .bos file I got the error . Do you have any idea why this error is happening. I am able to import other .bos files without issues.

!ENTRY org.bonitasoft.studio.ui 4 0 2019-07-10 20:39:50.592
!MESSAGE
!STACK 0
java.lang.IllegalArgumentException:
at org.bonitasoft.studio.importer.bos.model.BosArchive.toImportModel(BosArchive.java:66)
at org.bonitasoft.studio.importer.bos.operation.ImportConflictsChecker.checkConflicts(ImportConflictsChecker.java:43)
at org.bonitasoft.studio.importer.bos.operation.ParseBosArchiveOperation.run(ParseBosArchiveOperation.java:42)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)

Thanks,

Submitted by laxmikant.latpa... on Thu, 07/11/2019 - 06:59

can you please share the log for the error from logs.

Submitted by laxmikant.latpa... on Thu, 07/11/2019 - 12:58

And this type error will come when you try to import .bos file from any latest version of studio to its prior version... can you check the version of studio you are using?

Kaant

Submitted by pooja.lnu_1403454 on Thu, 07/11/2019 - 15:10

HI Kant, I am using studio version Version : 7.9.0 Build id : 7.9.0.
Also there are no error on the engine log . Only studio log is showing the error

!ENTRY org.bonitasoft.studio.ui 4 0 2019-07-10 20:39:50.592
!MESSAGE
!STACK 0
java.lang.IllegalArgumentException:
at org.bonitasoft.studio.importer.bos.model.BosArchive.toImportModel(BosArchive.java:66)
at org.bonitasoft.studio.importer.bos.operation.ImportConflictsChecker.checkConflicts(ImportConflictsChecker.java:43)
at org.bonitasoft.studio.importer.bos.operation.ParseBosArchiveOperation.run(ParseBosArchiveOperation.java:42)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)

Submitted by laxmikant.latpa... on Thu, 07/11/2019 - 15:20

hey pooja
if you are taking the bos file from prior version to 7.9 studio then this should not happen. One more thing we should not import bos file from subscription edition to community edition or vice versa.
I guess you will find some engine log after that error populates...check once.

Submitted by pooja.lnu_1403454 on Fri, 07/12/2019 - 02:00

Hi Kant,

I had 2 .bos file. I installed v7.9.1 and imported one of the .bos file and it worked fine. So your suggestion was correct. For the other .bos file I am still facing issue but i think i am fine for now. Thanks again for helping. Really appreciate.

Submitted by laxmikant.latpa... on Fri, 07/12/2019 - 07:00

just import with fresh bos file that will also be fixed and what was your actual requirement ? db access using db connectors ?

Notifications