How to call any rest api from IDM endpoint

This topic has 2 replies, 2 voices, and was last updated 6 years, 3 months ago by Gajendra04.

  • Author
    Posts
  • #9985
     Gajendra04
    Participant

    Hi,

    I have a requirement to send the sms otp to users mobile number. I am having the sms gateway rest api. I have written end point to generate the otp. Now I am unable to call the sms gateway rest api from openidm custom endpoint.

    I am using openidm 4.

    Any help will be appreciated.

    Regards
    Gajendra

    #9991
     andi
    Participant

    See the Chapter 21. Accessing External REST Services in the integrator’s guide
    https://backstage.forgerock.com/#!/docs/openidm/4/integrators-guide/chap-external-rest

    From script follow the instructions on calling
    openidm.action(“external/rest”, “call”, params);
    with the appropriate settings for params as described in
    21.1. Invocation Parameters

    HTH
    Andi

    #10028
     Gajendra04
    Participant

    Hi Andi,

    for the testing purpose I am trying to call Openam authenticate rest api from endpoint, but I am getting below error.

    endpoint code:

    (function () {
    logger.info(‘Calling external rest api :’, null);
    url=”https://ccdevidaas.compucom.com/openam/json/authenticate”;
    data={“url”: url,”method”: “GET”,”headers”: {“X-OpenAM-Username”: “amadmin”, “X-OpenAM-Password”: “password”,”Content-Type”: “application/json” }};
    result=openidm.action(‘external/rest’, ‘call’, data);
    logger.info(‘result is :’+result, null);
    return ‘Success’;
    }());

    error:

    Apr 26, 2016 2:32:21 AM org.forgerock.script.scope.FunctionFactory$1$3 call
    INFO: Calling external rest api :
    Apr 26, 2016 2:32:21 AM org.forgerock.openidm.external.rest.RestService setAttributes
    INFO: Adding header X-OpenAM-Username: amadmin
    Apr 26, 2016 2:32:21 AM org.forgerock.openidm.external.rest.RestService setAttributes
    INFO: Adding header X-OpenAM-Password: password
    Apr 26, 2016 2:32:21 AM org.forgerock.openidm.external.rest.RestService setAttributes
    INFO: Adding header Content-Type: application/json
    Apr 26, 2016 2:32:21 AM org.restlet.ext.httpclient.HttpClientHelper start
    INFO: Starting the Apache HTTP client
    Apr 26, 2016 2:32:21 AM org.restlet.ext.httpclient.internal.HttpMethodCall sendRequest
    WARNING: An error occurred during the communication with the remote HTTP server.
    javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509)
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
    at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:543)
    at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:409)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144)
    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:882)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
    at org.restlet.ext.httpclient.internal.HttpMethodCall.sendRequest(HttpMethodCall.java:347)
    at org.restlet.engine.adapter.ClientAdapter.commit(ClientAdapter.java:114)
    at org.restlet.engine.adapter.HttpClientHelper.handle(HttpClientHelper.java:112)
    at org.restlet.Client.handle(Client.java:162)
    at org.restlet.routing.Filter.doHandle(Filter.java:159)
    at org.restlet.routing.Filter.handle(Filter.java:206)
    at org.restlet.resource.ClientResource.handle(ClientResource.java:1104)
    at org.restlet.resource.ClientResource.handleOutbound(ClientResource.java:1188)
    at org.restlet.resource.ClientResource.handle(ClientResource.java:1059)
    at org.restlet.resource.ClientResource.handle(ClientResource.java:1035)
    at org.restlet.resource.ClientResource.handle(ClientResource.java:937)
    at org.restlet.resource.ClientResource.get(ClientResource.java:645)
    at org.forgerock.openidm.external.rest.RestService.actionInstance(RestService.java:228)
    at org.forgerock.json.resource.InterfaceSingletonHandler.handleAction(InterfaceSingletonHandler.java:34)
    at org.forgerock.json.resource.Router.handleAction(Router.java:241)
    at org.forgerock.json.resource.FilterChain$Cursor.handleAction(FilterChain.java:59)
    at org.forgerock.json.resource.Filters$ConditionalFilter.filterAction(Filters.java:52)
    at org.forgerock.json.resource.FilterChain$Cursor.handleAction(FilterChain.java:57)
    at org.forgerock.json.resource.Filters$ConditionalFilter.filterAction(Filters.java:52)
    at org.forgerock.json.resource.FilterChain$Cursor.handleAction(FilterChain.java:57)
    at org.forgerock.json.resource.Filters$ConditionalFilter.filterAction(Filters.java:52)
    at org.forgerock.json.resource.FilterChain$Cursor.handleAction(FilterChain.java:57)
    at org.forgerock.openidm.audit.filter.AuditFilter.filterAction(AuditFilter.java:96)
    at org.forgerock.json.resource.Filters$ConditionalFilter.filterAction(Filters.java:50)
    at org.forgerock.json.resource.FilterChain$Cursor.handleAction(FilterChain.java:57)
    at org.forgerock.openidm.servlet.internal.ServletConnectionFactory$5.filterAction(ServletConnectionFactory.java:492)
    at org.forgerock.json.resource.FilterChain$Cursor.handleAction(FilterChain.java:57)
    at org.forgerock.openidm.maintenance.impl.PassthroughFilter.filterAction(PassthroughFilter.java:42)
    at org.forgerock.openidm.maintenance.impl.MaintenanceService.filterAction(MaintenanceService.java:218)

    Regards
    Gajendra

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

©2022 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?