How to use REST Connector to get data from REST API Extension
I use REST API Extension to retrieve some data from third-party software. I want to integrate that in the process using REST Connector. Apparently, the result always error 401 which means unauthenticated.
So is there a way for me to use the REST API Extension from the Process?
1 answer
Hi Yosi,
when you call a rest API extension from a REST connector, you need to authenticate since the HTTP call is done on server side and don't includes your api token
you could call:
- first the login service (https://documentation.bonitasoft.com/bonita/2021.1/rest-api-authentication)
- then extract the X-Bonita-API-Token
- then use a second rest connector with this token as a header
- then logout
This is not the best way to do since it requires to call 3 REST connectors and keep token in a transient variable.
instead:
- extract the business logic of your connector (all except parameters parsing and json rendering) to a java jar
- include this jar as a dependency to your rest api extension & your process
- use a groovy script connector that will use you extracted jar
Regards,
Laurent