#1 2021-04-14 08:24:04

Stéphane
Member
Registered: 2020-09-30

Scripting datasource for a rest api

Hello,

I'd like that a datasource uses a rest api.

First, i create a script to use the rest api but there is already a problem:

def connection = new URL( "https://[NUXEO]/nuxeo/site/api/v1/query?query=" +
        URLEncoder.encode(
                "SELECT * FROM Document", 'UTF-8' ) )
        .openConnection() as HttpURLConnection

// set some headers
//connection.setRequestProperty( 'User-Agent', 'groovy-2.4.4' )
//connection.setRequestProperty( 'Accept', 'application/json' )

// get the response code - automatically sends the request
println connection.getInputStream()

I obtain this result

Script execution failed.
error message: javax.script.ScriptException: java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext) (java.net.SocketException)
script arguments:
file: CartoNuxeoScript.groovy (id: 576037, line 35)
line number: 35 (25)

How can we use REST API ?

Thanks

Offline

#2 2021-04-14 11:45:36

eduardo
Administrator
Registered: 2016-11-01
Website

Re: Scripting datasource for a rest api

Hi Stéphane,

this seems to be a java >= 9 issue, pls check here:
https://reportserver.net/en/tutorials/i … -practice/

If you use Java 9 or newer, you need some extra configuration which can be done in the setenv.sh of your Tomcat environment. Specifically, the following configuration is needed:

--add-opens=java.base/java.net=ALL-UNNAMED
--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED
-Djavax.net.ssl.trustStoreType=JKS

In particular, adding -Djavax.net.ssl.trustStoreType=JKS should solve your problem. But we recommend adding the other options as well.

For windows, you can find the guide here: https://reportserver.net/en/tutorials/i … n-windows/

Regards,
Eduardo

Offline

#3 2021-04-14 11:50:23

eduardo
Administrator
Registered: 2016-11-01
Website

Re: Scripting datasource for a rest api

Hi Stéphane,

this seems to be related if you need more information:
https://github.com/jruby/jruby/issues/5808
https://bugs.openjdk.java.net/browse/JDK-8194702

Regards,
Eduardo

Offline

#4 2021-05-04 11:57:18

Stéphane
Member
Registered: 2020-09-30

Re: Scripting datasource for a rest api

Hi Eduardo,

Very well, it's ok with the args you give

Thanks

Offline

Board footer

Powered by FluxBB