How to send file to 3rd party app

Hi all,

I need other options than using webreports or appworks to send files to 3rd party applications. There's limitation on sending files to 3rd party app using webreport (please refer to article KB17044483). Your quick response will be appreciated.

Thanks,

Zefry

Comments

  • Specify perhaps what version of CS and the amount of programming you can write . CS has no limitations on size but many things like network and other aspects can cause impediment. CWS which you will write in either java or . Net won’t have typically that restriction. However if your application is a mobile app there is no expectation of a B2B purpose there
  • I re-read KB17044483 and I am thinking what is the role of WR here? Traditionally if one needed to Upload/Download CS has its API's both CWS(SOAP-based) and REST(newer API) or even Oscript. They both do not have the WR RestClient limitation. So if the intent was to send files from CS or to CS there is no File System limitation. I think it manifests only if you are wrapping your sending code in a WR Object and Using RESTclient as the vehicle. Even the RESTclient of Oscript probably doesn't have this limitation. So if there are ways you can design your product without using WR RESTclient it could work.

  • Hi Appu Nair,

    Here is our case: A specific user in our OTCS needs to send a PDF or DOC file from a specific folder in the OTCS to our partner's Server. They already provide a series of REST API end-points for us to use. There are three parts of API that we should use for the business purpose:

    1. UPLOAD. We upload a file to our partner's server to be processed on their site. The input: a file from a specific folder of the OTCS. The response is a reference_id to the uploaded file.
    2. PROCESSING STATUS. We could use this end-point to check the status of our file on our partner site. The input is the reference_id from part 1 above.
    3. DOWNLOAD. We could download back our file from the partner site and we need to save it as a new version of that file in our OTCS. The input is the reference_id of the file.

    Would you give me a suggestion on which OpenText solution we could use for that case? Where I can find the Oscrpt's documentation or a how-to code the REST API consumption in the OScirpt for our case?

    Thank you in advance.

    Best Regards,

    Zefry

  • @Zefry Wirya

    For scenario1:What is the webpage/application user sees. Is it a CS SmartUI page, A custom front end, or what? I would probably create a JOB (something that works on a schedule a batch file that can take some parameter). So it will know the folder,it will have a query listing the File.At the end oif it it will use REST API or CWS to do what you say . Likewise all your scenarios can be written custom code.

    if you want things not to wait on a scheduler consider writing Oscript . I did not say use WR triggers as you have said your WR route is less than ideal


    an example like your process

    to me what you suggest is what Brava does in a way you say you want to open a file in Brava . Whatever the file size is CS Oscript sends the file , Brava crunches the file and sends back the version , to the user it looks like synchronous but huge file sizes and processing are handled usually by custom written code OT Rest and OT soap and Oscript are usually used in such integrations

    #AOTXECM5D

  • @Zefry Wirya WebReports does have a RESTClient tag that you can use that for the file upload and processing steps. I suspect you could also create a Scheduled WebReport to do the download for you from the other system back into Content Server.

    With the REST Client, also check out https://forums.opentext.com/forums/developer/discussion/298774/uploading-documents-from-webreport-using-restclient-subtag-from-one-content-server-to-another and its associated KB Article https://knowledge.opentext.com/knowledge/llisapi.dll/kcs/kbarticle/view/KB17044483?_ga=2.91187802.196278330.1624842851-193628321.1583177058.

    There are other development options depending on your access and skills etc.

  • Hi Appu Nair,

    Regarding the UI used by our users, it will be great if we can use the CS SmartUI but we also consider using a custom front end if we can not custom the CS SmartUI for the case. But, either way, we don't know how to start to build the UI, that's why we tried using WR with its RESTClient tag in the first attempt which is failed because it can not POST a file from the OTCS to the outside server (or it could be me the one who doesn't know how to use the tag to POST a file, CMIIW please).

  • zefry
    edited August 5, 2021 #8

    Hi @Greg Griffiths We've tried using the RESTCLIENT in WR but failed. We also have drop questions in the links you gave which is end up in a "feature request" KB17044483.

    The only documentation we could read about the WR's RESTCLIENT tag is from the WR editor's Tag Guide, we could not find how to use @PARMS or @BODY in the tag there for POST a file from the OTCS to the outside server. We've also searched the forum about that tag. Do you have the detailed documentation about how to use the tag especially about POST a file?

    Thank you in advance.

    Zefry


  • zefry
    edited August 5, 2021 #9

    Hi all,

    For the Upload scenario, our partner's server has a REST API endpoint with a specification like this:

    Host: https://thesandbox

    Endpoint: /v2/document/upload

    Method: POST

    Request:

    Header - Content Type:  multipart/form-data

    Header - apikey: the-client-token

    Body Parameter:

    • document: Type: File
    • email: Type: string

    For this scenario, I setup a workflow that the user could select a document from the OTCS, then the user submit the step, then the workflow continue to the next step which is executes a WR script to do the upload using LL_WEBREPORT_RESTCLIENT tag. Bellow is the code, please correct me and guide me how to use the tag correctly and how to debug or view the WR log that executing the RESTCLIENT. Pls note for the test purpose, I hardcoded the document's node id (209595)

    [LL_REPTAG_{ { "apikey", "the-client-token"}, {"Content-Type", "multipart/form-data"} } ASSOCACTION:CREATE SETVAR:varHeaderAssoc /]
    [LL_REPTAG_{ { "email", "email@example.com" }, {"document", [LL_REPTAG_'209595' /]} } ASSOCACTION:CREATE SETVAR:varParamsAssoc /]
    [LL_WEBREPORT_RESTCLIENT
    @HOST:[LL_REPTAG_$ApiHost /]
    @PORT:443
    @SECURE:TRUE
    @URI:"/v2/document/upload"
    @HEADER:[LL_REPTAG_!varHeaderAssoc /]
    @METHOD:POST
    @PARMS:[LL_REPTAG_!varParamsAssoc /]
    @OUTPUT:ASSOC:varOutputAssoc /]
    

    But that code doesn't work. If I add [LL_REPTAG_!varOutputAssoc INSPECT /] it shows an error "No context returned from POST call to /v2/document/upload"

    Please show me what have I missed here and how/where could I view the detailed log?

    Thank you in advance.

    Zefry

  • You should see some output in the Server logs, I cant see your OTCSTicket being passed in the REST call, is this REST call going to an OT server or a different application ? if the latter, you would need to Stream/download the file and then push/upload the file to the other application.

  • Ferdinand Prantl
    edited August 5, 2021 #11

    There is an example commands/rename in the Smart UI SDK, which shows how to put a button on a toolbar, which performs renaming of a node using a modal dialog and a server call. But a pure browser customisation for moving files between two servers is usually a bad idea.

    Pros: You do not depend on the capabilities of the REST client in OScript. You have the full power of the AJAX in the browser, which is usually enough for anything. (Just pay intention to CORS support.)

    Cons 1: Your code does not run on the server, which means that whatever you got from KINI or other tables, you have to get somehow to the client side. It usually means an AJAX call to (probably your custom) CS REST API, or global settings can be sent from CSUI::Extension:GetDynamicConfiguration.

    Cons 2: Trafficking big files around using the connection server1-browser-server2 instead of server1-server2 will become annoying if the user has a tablet on a slow wifi.

    If your scenario was about posting short requests for status changes, it would be fine. But moving big data between server usually implies the server1-server2 communication.

  • zefry
    edited August 5, 2021 #12

    Hi @Greg Griffiths This REST call is going to a different server, not an OT. It is our business partner's server.

    How to do the stream & push using WR script?

  • Hi @Ferdinand Prantl Yes, we need the server1-server2 communication. The server1 is our OTCS and server2 is our business partner's server.

    We've tried the AJAX and yes it hit the CORS policy and we have to avoid it, so we can not use the browser-based solution.

    Our documents to be trafficking are not big in size, they only view pages of PDF or DOC businesses letter.

    At the first time, we considered using the WR script because it is a less code solution, has less learning curve than the OScript, and is easily integrated with the workflow.

  • @Zefry Wirya I am sorry to confuse you even more than it is necessary but I think it necessary now that I understand your problem a little more clearly.If you were able to find a partner in crime who knows oscript here is a very simple way to get what you need.

    • Something tells me that your process is relying on a workflow step at some point.
    • You need an Oscript developer to create a simple event script for 4-8 hrs for a medium developer. This is not the full code this is to get a module and other plumbing done. experienced Oscript developers may very well do this in 1 hr or so.
    • The event script will fire when the WF step that you have the REST code WR running think of it as an intelligent replacement to that WR step.
    • When the event script fires either it ahs the things you need like the file to be sent and what not. The event script Oscript developer will take that and prepare to call the external system. Simply put the event script will get either the REST worked or not
    • Depending on what you want with that you add the other file that you got from the other system as a version to the original file

    This whole project can be then estimated correctly or coded by you if you were to do Oscript. I assume you come from a programming background like Java or. NET. Oscript will look terribly confusing at first but nevertheless, a lot of people working in Content server does that for a living.

    Variations:

    The event script can be made into a custom WR tag, the only advantage there is you get to call the event script via a WR step. Still, the code is written in Oscript. Once you are in Oscript you have several ways to talk to other systems the easiest is to make it go through Java.

    You can buy Answermodules package which runs "scripts" inside CS. The scripts are written in "groovy" so a lot of java people will take to it like fish naturally.

    I won't offer any more comments I promise...

    #AOTDEV13D

  • Hi, @Appu Nair Thank you so much for your suggestions. I really appreciate it. It brings me a brighter light. I will consider your suggestion about finding an OScript developer to save my day.

    Best regards,

    Zefry

  • Zefry,

    Going back over your thread, you mention that the business partner has an API that

    1. UPLOAD. We upload a file to our partner's server to be processed on their site. The input: a file from a specific folder of the OTCS. The response is a reference_id to the uploaded file.
    2. PROCESSING STATUS. We could use this end-point to check the status of our file on our partner site. The input is the reference_id from part 1 above.
    3. DOWNLOAD. We could download back our file from the partner site and we need to save it as a new version of that file in our OTCS. The input is the reference_id of the file.

    I can't recall seeing anything mentioned about how the partners APIs are authenticated against. I'd take that into consideration - e.g. if the partner were to require an oAuth secret, how would you securely store that in a WebReport/AJAX based solution etc.

    Furthermore, have you considered what Content Server user will perform the upload and if required download. Do be aware that this enters into licensing territory - i.e. Content Server relies on named users and the use of the admin account or a "system account" for this purpose may be viewed as requiring "transactional licenses" (volume based). If the volumes of upload/download between CS and the partner are going to be of reasonable frequency, I would tick this question off early so you're clear you're within the usage terms of the OpenText EULA.

    Regards,

    David

  • If the original REST endpoint does not support CORS, proxies are usually installed and configured. AppWorks include such proxy for the connected services, including CS, but there are many other solutions including Apache and NGINX. But more effort, an additional service would have to run.

    Yet another solution would be implementing the document transfer outside CS, using the technology that you prefer. A user-click in the browser would issue an AJAX request to your service, that service would download a document from CS and upload to the 3rd-party server. The communication would stay on the server backbone. But again more effort, an additional service would have to be written.