API Connector

Hi Everyone,


How can I check if the API is installed/working - to be able to change this? I'm connecting to CS on a VM - in relation to https://forums.opentext.com/forums/developer/discussion/302858/overwrite-smartui-menu-functions-in-custom-oscript-module



Comments

  • Ferdinand Prantl
    Ferdinand Prantl E Community Moderator

    Are you asking about how to find out if a REST resource /api/... is available on the server?

    You pasted an example of a mocked connection used in unit tests. I do not understand the relation to your question.

  • in your screencap, you show this URL.//server. A typical livelink URL is like this

    HTTP(s)://<server>/<OT VIRTUAL DIRECTORY>/<CGI SCRIPT>

    so the KB we are on runs in Livelink software so see this or click this

    https://knowledge.opentext.com/knowledge/cs.dll/open/home

    the CS REST API starts at the end of the script so if OT allowed me to GET/POST anything on this server it would be

    https://knowledge.opentext.com/knowledge/cs.dll/api/v1 -- you put this URL say in Postman to test the API

    When you deploy your smartui project using a script module the resources will be under the configured server support directory.

    So to check access to your API if you have access RDP to the server holding your code and check if the Livelink URL looks like

    what I have shown above and then use postman to get a OTDS Ticket or OTCS Ticket and replace the ticket with that

    In typical smartUI things that work from OT meaning OT provides the code

    see this for an example we change the code appropriately here


    var folderBrowser = new FolderBrowserWidget({
    	connection: {
    		url: 'http://cs.example.com/OTCS/cs.exe/api/v1',
    		supportPath: '/img',
    		credentials: {
                   username:'<username>',
                   password:'<password>'
                 }
    


    To get that example going one changes that to a real working Livelink server replacing the username and password. In my implementation, I change the username/password to a header called OTDSTicket.

  • ---Are you asking about how to find out if a REST resource /api/... is available on the server?

    Yes

    It looks like it's not - no wonder I've been running into walls to get my Smart UI to run/work/display. I'm running Content Server 20.2, build 16.2.12.1144 - an instance I haven't installed.

  • Apparently, I seem to think from one of your screenshots you had CSIDE running then that is the working Livelink Server/Content Server

    You cannot develop Oscript if you do not have a content server installed so REST API is actually implemented in Oscript :)

    In simpler terms

    Content Server a.k.a Livelink actual Document Management Server that has a DB.webserver and so on.

    REST API get/Post asking for resources against that guy.

    SmartUI SDK-Create reusable JS components against CS.

    just wondering how one develops in script without a working CS?

  • Yes my CS is running on a VM. If I want to access the http://localhost/otcs/cs/api/v1 - I get a 404 - I've enabled it on the Admin Pages. I can't test the custom Smart UI without being able to connect to the VM CS.

  • Ferdinand Prantl
    Ferdinand Prantl E Community Moderator

    /api/v1 will always fail with 404 because it is not a valid resource URL. If you want to check the presence of a server you can use /api/v1/ping which does not need an authentication. If you get 200, the server is running.

    About a concrete REST resource URL, there is no optimal way to find out if it is available. You can choose from 1B and 2B below.

    • 1B asks exactly about the resource that you need, but it costs one server call.
    • 2B needs no server call but you need to know what is the minimum CS version that introduced the particular resource.

    If I got a single feature to handle, I would choose 2B, because saving REST calls is very important for browser applications. The code supporting obsolete servers should be pruned regularly.

    General Approach

    1: Check if the API is available.

    2: Find out the server version and compare it with the version that you know that includes your feature.

    Concrete Options

    1A: Just make a REST call to /api/... that you prefer executing. If you get a 404, either make a different call, if a workaround is feasible, or tell the user that your feature is not available on that server.

    1B: Spend an extra call to enquire about a resource. For example, /api/v1/apiinfo?resource=api/v1/nodes/2000. 200 means, that the URL is recognised, 404 that it is not.

    2A: Use some undocumented REST call like /api/v2/admin/info to get the server version and build. For example:

    /api/v2/admin/info
    {
     "results": {
      "build": "1404",
      "update": "21.1",
      "version": "16.2.15"
     }
    }
    

    2B: Ask for the Smart UI core version in JavaScript. For example:

    csui.getVersion()
    // Returns "21.1.0.6544"
    
  • I literally get 404 on all those options - so can't even get the basic info one.

  • Appu Nair
    Appu Nair Member
    edited March 23, 2021 #9

    A 404 sometimes means that your windows IIS that you are running Content Server has Integrated Windows authentication.REST will not work with IWA so you can make that anonymous and you will see success. If you are running CS on TC or something else suitable adjustments to make sure you are accessing the server non-authenticated a.k.a anonymous.

    How to check that is going to IIS of your CS and change its website to be anonymous check both the application support the whole deal

    Now without using your code just do a simple postman request with userid/password do the simplest of examples in developer.opentext.com

    BTW before someone jumps and says what I have said is wrong -- I have not seen OT REST API handling IWA tokens ever so thought I would ask if that is your problem. A hardcoded userid/password method is provided by OT to help developers when the server trusts "Basic Authentication" . in IWA what works for CS access and not rest API is when you click a CS URL if OTDS is configured to use the user's Kerberos token it will log you in and return an OTDSSSOTICKET. This ticket can be put as OTDSTICKET as in the header for all other API calls. To make all that easier is what I suggested make your CS anonymous :)

    My$0.02

  • Thank you Appu Nair - it makes my troubleshooting easier.

    My CS website - all of it are indeed Anonymous Authentication Enabled on IIS. If the CWS are installed/setup that counts for the API to be set up too? Or am I understanding that incorrectly. We've never had a project where we've used API before, so only realizing issues now that I want to work with the Smart UI SDK.

  • Appu Nair
    Appu Nair Member
    edited March 23, 2021 #11

    Quick check-in my system when I execute smart view showing OT's REST API works

    In case SmartView is not on and you want to go from Classic to Smart

    If OT's REST API works and your s doesn't compare what could be wrong. All OT REST APIs are known in the Oscript registry....

    However, my understanding(which I do not know much) is that SmarTUI always does not need an OT REST API it can of course get its data

    from an existing REST endpoint. If your smartui project was somehow designed to work with your own rest API then there are steps to register

    your rest API in oscript.I recently needed an API endpoint custom so I created an endpoint for that, but my project does not require the smartui as I just needed the json output for something :) One of these days I might need a smartui page so I might get better...


    CWS is the SOAP endpoint several years mature, it is used by OTDS to create users and groups but if you use otadmin@otds.admin whether internal or external that user access should be a good one to test things with.

  • thank you :) :) I will quickly trouble shoot that :)

  • Alright so obviously if you have Smart View then API is working, thanks got that technical part now :)

    Just still doesn't understand why the plain hello page will be blank - and yes I have started the server in CMD for http://localhost:7777/ on my laptop, and then in the hello.html page and js files I have that VM url


  • Curiously, should/can I update the server.js file instead (only)? I'm accessing my VM CS url with an IP address.



  • In many posts prior in this and others you will see Ferda saying the SUI SDK that works completely within the nodejs environment needs to be transported to the content server under its support (img) directory through a Oscript module .So long as it is designed to work with a CS Rest Api.The Oscript module in this context has only one role make sure that when the SUI is loaded the response is coming from CS . I don’t know the local host:7777 part perhaps a CS page requests it from there ?

    My gut feel is some confusion exists what the role of the nodejs/NPM/Yeoman commands vs what runs in CS . If you open that CS server using its file system and then go to the support directory you will see a folder called csui you will see a lot of things that look like what you are developing there ...

    Sorry I am trying to help I do not ever had a need to come up with a SUI so a lot of my guesses maybe wrong

    Ferda is the be all end all of SUI if he says do that I would believe that?
  • I had difficulty getting the nodejs/NPM/Yeoman going on the VM that's why i'm trying to develop in the SDK on my laptop, where all that is already installed. I also think that perhaps if I was able to get the nodejs/NPM/Yeoman working on the VM perhaps it would be easier - but spend days and couldn't get it to work.

  • Appu Nair
    Appu Nair Member
    edited March 23, 2021 #17
    Why does your url in livelink end in cS if it’s windows it has to be livelink.exe , Cs.exe , LLisapi.dll or Cs.dll if the url to access livelink classic is CS that would suggest Linux or a TC deploy ? I think the intent of the SUI SDK is you are playing with a dummied response of what an actual rest api delivers . So if that thought is correct then my mind tells me your SUI project needs to sit in the support directory of content server .that is why I pointed to the csui folder which shows the artifacts of the SUI not everything in the SDK but stuff from the out-release I guess of your project ...

    See Ferda's reply https://forums.opentext.com/forums/support/discussion/303178/smartui-sdk-test-widgets-load-into-our-opentext-instance
  • Ferdinand Prantl
    Ferdinand Prantl E Community Moderator

    CS REST API requires Anonymous Authentication. Non-windows clients need to be able to pass the authentication token will be passed in a custom request header (OTCSTicket), instead of depending on IWA built-in to IIS, which is windows-specific.

    If you need IWA for Classic UI, you will need to create another web application in IIS for the /opentext/cgi directory and disable IWA there. That alternative URL woudl be used by REST clients.

  • Thank you both! May I ask what you mean by IWA, I will have to pass this info on to our Administrator. My VM is in Windows Server, will an environment in Windows be better?

  • Ferdinand Prantl
    Ferdinand Prantl E Community Moderator
    edited March 23, 2021 #20

    Having the Smart UI development environment on a laptop or separately from the CS VM is usual. You need common JS tools like VS Code, nvm with a couple of version of Node.js there and NPM modules like Yeoman etc. A front-end development environment. VMs with CS are often exchanged to test with different CS versions. You do not want to install the Smart UI development environment constantly there.

    The configuration in your latest post looks well. When the page fails loading, you will need to check the dev. tools console and if it shows an AJAX error, then the network panel for details.

  • Ferdinand Prantl
    Ferdinand Prantl E Community Moderator

    IWA means Integrated Windows Authentication.

  • Alright thank you, nice to know I'm on track in the right direction, I will check for errors.

  • @Ferdinand Prantl the post you say it is OK why does the URL masked end in cs usually on windows isn't it cs.exe ,llisapi.dll and so on? that is the CGI for livelink isn't it or is he getting a response from the Nodejas environment with that code?

  • Ferdinand Prantl
    Ferdinand Prantl E Community Moderator

    Good catch, Appu! I am sorry for missing it.

    Yes, it is most probably wrong. /cs could be configured by URL rewriting, but a typical windows server needs .../cs.exe/api/v1 and if ISAPI filters are enabled then preferably .../llisapi.dll/api/v1.

    Natashja, you will need to fix the connection URL, as Appu wrote.

  • Thank you both, I no longer get the 404 error.