Hi, I’m brand new to Bonita so please excuse my terminology.
I’m looking to use the REST API Connector to connect of a REST API of a Java service to extract data from a MySQL database. The format of the API is basically multiple Customers where each Customer has multiple Suppliers. There are other fields like Name, email address etc. I’ll use in the workflow. I’m extracting these so I can send an email to the Customer and each supplier of that Customer, I can send emails via the email connector.
The challenge I’m having is extracting data from the REST API to use in the workflow. I can connect to the API successfully but how do I go about making data in the API available to the workflow ?
Kind Regards,
David.
If this task stream is not UI based then there is no need to use the UI, just use the already available MySQL Connector.
This will enable you to extract the data, return it to your workflow and then process it accordingly.
This is something we do all the time and is quite easy.
regards
Seán
PS: As this reply offers an answer your question, and if you like it, please Mark UP and/or as Resolved.
And to complete, if you have to use an existing REST service, then you can use the REST connector.
If the service you call returns a JSON object, to use it, you just have to :
- Create a process variable
- Configure the REST Connector
- In the last configuration screen : select the variable you created to assign the result (bodyAsObject or bodyAsString)
- If needed, you can add a script Connector to parse the variable and get all the Suppliers for your Customer
If it returns a String object, you will have to parse it and get the informations you need in the string.
Hi Sean,
Thanks for your reply, I’ve also tried this method.
This is not a UI based task, its collect some data then make a decision on which email to send and repeat 3 times.
The challenge I’m having is that I can extract the data from MySQL, how do I process the data from there. I’m new to Bonita and don’t understand the process of what I need to setup to use the data. Any advice would be welcome ?
Hi Pierre,
You make it sound so easy.
The service returns a JSON object.
I setup the process variable as a Java Object, however, when configuring the REST connector it says that its incompatible with bodyasObject.
I’ve created a services task where I’ve created the connector in the connectors in, should this be at pool level ?
I cant find any documentation on bodyasObject to understand how to configure and use it, do you know of anywhere I can find this information ?
Hi David,
That’s why I said “if needed, you can add a script”.
What you could is saving the service result in a string variable (using bodyAsString), and then in a script connector, get the values in the string variable and set your java object.
Otherwise, you could try with the bodyAsObject to add multiple actions to set values on your Java Object (never tried that solution). I did an example : http://imgur.com/ukpNvAz
Select your java object, select the ‘set’ method, click on the pen, select script, and get the value in the bodyAsObject
Sounds good ?
Hi Pierre,
Sounds good, I’ve tried to follow your example but I’m still struggling with the process of setting up the connector to extract the data and putting it into usable fields. Do I need to setup the fields before setting up the connector.
Setting up the Connector to connect to the REST API is easy but understanding how the data is extracted is not, the documentation doesn’t help much.
If you have 10 mins free, it would be good to maybe skype to show you what I’m doing and you can tell me where I’m going wrong ?
David.
Hi David,
Can you provide me the script to convert from Json and save the value in bonita bpm db through Rest Connector.