How to use REST Connector to get data from REST API Extension

1
0
-1

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

1
+2
-1
This one is the BEST 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:

  1. first the login service (https://documentation.bonitasoft.com/bonita/2021.1/rest-api-authentication)
  2. then extract the X-Bonita-API-Token
  3. then use a second rest connector with this token as a header
  4. 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:

  1. extract the business logic of your connector (all except parameters parsing and json rendering) to a java jar
  2. include this jar as a dependency to your rest api extension & your process
  3. use a groovy script connector that will use you extracted jar

Regards,

Laurent

Notifications