TRIRIGA

 View Only
  • 1.  Admin REST API information

    Posted Fri January 06, 2023 10:07 AM
    I am seeking any java sample code (or curl snippets) that utilizes the Tririga Rest Administration API, as specified here: API documentation - IBM Documentation.
    • How is a client to the admin API authenticated?
    • How is authentication/authorization passed to API calls


    ------------------------------
    James Combs
    ------------------------------

    #AssetandFacilitiesManagement
    #TRIRIGA


  • 2.  RE: Admin REST API information

    Posted Mon January 09, 2023 11:06 AM
    Edited by System Wed March 22, 2023 11:43 AM
    Hi James,

    The following information will help!

    How is a client connected to the admin API authenticated?

    • Use the following link to authenticate: 
    https://{ServerHostName}{:port}/{context}/html/en/default/admin/verify.jsp

    • Use the following cURL example to connect.  The -o flag is required to pass the unwanted HTTP output to a file, and the -c flag is used to capture the cookie response in a file.
    curl -X POST 'https://{ServerHostName}{:port}/{context}/html/en/default/admin/verify.jsp' \
    -F 'objectId=1000' -F 'actionId=1002' \
    -F 'USERNAME=adminuser' -F 'PASSWORD=password' \
    -o not-needed -c cookies.txt

    • The cookie.txt file will have a similar context as below once you have authenticated successfully:
    #HttpOnly_tririga.tririga.com FALSE / TRUE 0 JSESSIONID 0000fkHpsCkqg8CBoHeBzUnsvuM:7a7325e7-d40a-40b9-8418-cffcf0304a8d

    How is authentication/authorization passed to API calls?

    • Once you have authenticated and have the JSESSIONID cookie from the cookie.txt file,  you can invoke the Admin APIs using the cURL commands below by using the cookie directly in the command line. You could also use the generated cookie.txt file by replacing the cookie header with -b cookie.txt
    curl -i -H "Accept: application/json" -H "Cookie: JSESSIONID=00002j_c1AB635jTCI42tTyi6oC:7a7325e7-d40a-40b9-8418-cffcf0304a8d" \
    'https://{ServerHostName}{:port}/{context}/api/V1/admin/summary'

    • The API above will give you an output like this:
    {
    "operatingSytem": "Linux amd64 null",
    "noofcpus": 4,
    "baseApplicationServer": "Liberty",
    "users": "3 users online",
    "network": [
    "linux xx.xx.xx.xx"
    ],
    "javaVersion": "IBM Corporation 1.8.0_211",
    "usedMemory": "1817 MB",
    "freeMemory": "2125 MB",
    "totalMemory": "3942 MB",
    "maxMemory": "4096 MB",
    "freeDiskSpace": "48081 MB",
    "freeTempSpace": "48081 MB",
    "tririgaBuildNumber": "296623",
    "databaseBuildNumber": 296623,
    "tririgaPlatformRelease": "3.8.0",
    "moduleLevelAssociation": "Not Enabled",
    "databaseConnection": "jdbc:db2://xxxx:50006/xxxx",
    "outgoingMailServer": "\"\"",
    "bravaServer": "Not Enabled",
    "crystalRas": "${crystal.hostname}",
    "internalCrystalRequestServer": "xx.xx.xx.xx:34891",
    "configuredforSso": "N",
    "baseCurrency": "US Dollars",
    "timeForPortalToRefresh": "60",
    "javaProcessIdOnHost": 4455443
    }

    • Another example could be related to the KPIs:
    curl -i -H "Accept: application/json" -H "Cookie: JSESSIONID=00002j_c1AB635jTCI42tTyi6oC:7a7325e7-d40a-40b9-8418-cffcf0304a8d" \
    'https://{ServerHostName}{:port}/{context}/api/V1/admin/performance/kpi'

    • The KPI command above will give you an output like this:
    {
    "Java Memory (Used/Free/Total):": "2231/1711/3942",
    "Logged In User Count:": 3,
    "Total Workflows Completed:": 160372,
    "Extended Formula Queue Count:": 0,
    "Java use of CPU (%): ": "2%",
    "Total Workflows Started:": 160372,
    "Cache Info (Hits/Object Count/Misses/Ratio):": "66189331/6578/140980/2,043%",
    "Workflow Events Throughput per 1 minutes:": 6,
    "Total Workflows Failed:": 0,
    "Active Database Connections:": 4,
    "Workflow Events Queue Count:": 0,
    "Total Workflow Steps Processed:": 1762817
    }

    This should help you get started! Let me know if you need any additional input.

    Regards!

    ------------------------------
    Shashank Agarwal
    ------------------------------



  • 3.  RE: Admin REST API information

    Posted Tue January 10, 2023 10:05 AM
    Edited by System Wed March 22, 2023 11:43 AM
    Thank you much, Shashank!  However, the server doesn't seem to respond to those API calls:  The cookie I get back isn't viable...and I get 'unauthorized.jsp' in the Location attribute of the return response.  I'm hitting Tririga version 3.6.1.3.  This is being actively discussed here as well:  🎭️ TRIRIGAFEEDIA Forum

    Here's a screenshot of my Auth call:




    ------------------------------
    James Combs
    ------------------------------



  • 4.  RE: Admin REST API information

    Posted Thu January 12, 2023 09:03 AM
    James,

    Could you try changing the url https://{ServerHostName}{:port}/{context}/html/en/default/admin/verify.jsp to https://{ServerHostName}{:port}/{context}/html/en/default/rest/Integration


    A sample usage for forcing users to logout is available here (it leverages the popular jq tool that's used to parse/query json documents)



    ------------------------------
    Kalyan Chakravarthy Vadlakonda
    ------------------------------



  • 5.  RE: Admin REST API information

    Posted Thu January 12, 2023 10:32 AM
    Edited by System Wed March 22, 2023 11:53 AM
    I tried your suggestion, Kalyan.  After some adjustments, it appears that the server is respecting the authentication; However, I get a 500 error back when I invoke 'activeUsers/list '.  The returned message indicates that an exception occurred on the server side.  Here are the changes I made:
    The authentication sequence seems far removed from the original details in the video IBM TRIRIGA Enhanced Platform Features - 3.8.0 Admin Console API (Beta) - YouTube.  But I'll take what I can get :) 

    Here's the command sequence and return payload:

    $ curl --verbose -c cookies.txt --user <username:password> 'https://<myplatform>/html/en/default/rest/Integration'
    (I get an OK 200 return message here...everything looks good)

    $ curl --verbose -b cookies.txt --header "Content-Type: application/json" 'https://<myplatform>/api/v1/admin/activeUsers/list'
    < HTTP/1.1 500 Internal Server Error
    < Date: Thu, 12 Jan 2023 15:13:12 GMT
    < X-Powered-By: Servlet/3.1
    < X-UA-Compatible: IE=edge
    < X-Frame-Options: SAMEORIGIN
    < Connection: close
    < Transfer-Encoding: chunked
    < Content-Type: application/json
    < Content-Language: en-US
    <
    {"message":"Could not write JSON: Joda date/time type `org.joda.time.DateTime` not supported by default: add Module \"com.fasterxml.jackson.datatype:jackson-datatype-joda\" to enable handling; nes
    ted exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Joda date/time type `org.joda.time.DateTime` not supported by default: add Module \"com.fasterxml.jackson.datatype:j
    ackson-datatype-joda\" to enable handling (through reference chain: java.util.ArrayList[0]->com.tririga.architecture.admin.helper.UserHelper[\"loginDateTime\"])"}* schannel: server closed the conn
    ection
    * Closing connection 0
    * schannel: shutting down SSL/TLS connection with <myplatform> port 443

    ------------------------------
    James Combs
    ------------------------------