Can't do GET function with GET Connector to a private IP API

1
0
-1

Hi, I wanna ask, I tried to use GET Connector for pulling data from API. The problem is when I try to use this GET function to a private IP address it seems like the connector can't find that IP address.

Here are the logs from the test function using Bonita Webservice Connector :

java.lang.reflect.InvocationTargetException
org.bonitasoft.engine.bpm.connector.ConnectorExecutionException: USERNAME=install | 
org.bonitasoft.engine.core.connector.exception.SConnectorException: java.util.concurrent.ExecutionException: org.bonitasoft.engine.commons.exceptions.SBonitaRuntimeException: 
org.bonitasoft.engine.connector.exception.SConnectorException: 
org.bonitasoft.engine.connector.ConnectorException: javax.net.ssl.SSLHandshakeException: PKIX path building 
failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to 
requested target

Now, I tried to pull data from a Public API and it worked just fine. I tried to use a sub-domain name but no luck.

Anyone can help me with this problem? Perhaps can anyone give insight? Is it probably related with tomcat setup (I need to setup a "thing" to resolve the DNS name like "/etc/resolv.conf" if on Linux)?

Thanks beforehand :)

Comments

Submitted by UndergradLads on Mon, 12/12/2022 - 08:05

Edit : After some digging around and set some things here and there (in my case changing Trust Certificate Strategy set to TRUST_ALL fix my problem), I didn't get the error code anymore. But instead, I got a NULL. I tried to use a "fake json" and fill the fake json with my return json, bonita can see the return json. But when I use the real json (in my case OpenProject's API), the return of the json is NULL (I've double check the json return with Postman and Browser's json reader and it seems fine (there is a response json)). Can someone give me more info about this problem? Thanks in advance! :)

Submitted by romain.bioteau on Wed, 12/14/2022 - 09:27

Hi,

Can you double-check the status_code output ? Are there any specific logs in the Runtime logs that could help troubleshoot your issue ? You may want to increase the log level to have more insights of what is happening during the call.

HTH
Romain

Submitted by UndergradLads on Thu, 12/15/2022 - 04:33

Hi, Thanks for the reply :)

I logged Bonita Engine and something catches my eye :

14-Dec-2022 17:42:48.066 WARNING [ConnectorExecutor-2] org.bonitasoft.connectors.rest.RESTConnector.parseResponse Body as map output cannot be set. Response content type is not json compliant(application/hal+json; charset=utf-8).

When I cross-check it with a Browser (Firefox), on the Header collumn, the Content-type result is application/hal+json; charset=utf-8, so I think the JSON seems fine.

Perhaps I missed something else? :( Thank you in advance !

Best Regards

Submitted by romain.bioteau on Thu, 12/15/2022 - 14:09

The current implementation of the connector check for a application/json response content-type before serializing the response body in the bodyAsMap output. As the content type is application/hal+json this output is not set. However, you should retrieve the bodyAsString output even when the response is not json.

Submitted by UndergradLads on Fri, 12/16/2022 - 04:20

Hi, thanks for the follow up..

I got JSON-like response using bodyAsString. But I wanna output data directly (using BodyAsObject.name for example) but I think it's not possible since the response is NULL using BodyAsObject output. Are there any workaround this? Thanks!

Submitted by romain.bioteau on Fri, 12/16/2022 - 09:51

Yes,

The way to go would be to use the groovy JsonSlurper on the bodyAsString output. It will return an object one could easily navigate in.

HTH
Romain

Submitted by UndergradLads on Wed, 12/21/2022 - 03:30

Hi, thanks for the info! I tried to use JsonSlurper script on GET Connector Output operations, but I don't know how to script it so it will output the object. Here is my code :

import groovy.json.JsonSlurper
def bas = bodyAsString
class Example {
   static void main(String[] args, bas) {
      def jsonSlurper = new JsonSlurper()
      def object = jsonSlurper.parseText(bas)
      println(object.name)
   }
}

And the output when testing are the one from the bodyAsString function. (First off all, I am new to the language :( )

So how can I use the JsonSlurper and then output the result just like when we use the bodyAsObject function? Thanks in advance!

Best Regards :)

No answers yet.
Notifications