Maximo Open Forum

  • 1.  restAPI File download

    Posted 07-08-2021 15:54
    We are calling a restApi call using the service.invokeEndpoint. The API returns a binary response and in turn create a file from it. We would like the file to be saved locally, but it always gets saved on the Maximo Server. Is there a way to save it locally ?
    Any help is greatly appreciated.

    Thanks,
    P. Seetharaman
    #Integrations

    ------------------------------
    Pratap Seetharaman
    DTE Energy
    ------------------------------


  • 2.  RE: restAPI File download

    Maximo Certified
    Posted 07-08-2021 16:18
    I don't understand how the script is firing. Do you have some background process (IE cron task), is the user taking an action (such as clicking a push button) that causes an automation script to fire, are your users making a REST API call into Maximo that executes the script, or some other scenario that I can't think of that then makes the API request to the external system?

    The reason I ask is how the script is firing will control what (if anything) can be done. I think based on the request you're talking about the second option because it's the only thing that I could think of that would logically download a file to your local filesystem. The second option might be tricky because you might have to temporarily associate as a DOCLINK to be able to invoke an event that would download the file.

    ------------------------------
    Steven Shull
    Projetech Inc.
    ------------------------------



  • 3.  RE: restAPI File download

    Posted 07-08-2021 20:21
    Thank You Steven. The Automation Script gets fired based on user clicking a button from the UI. The Script would make the API Request to an external system to retrieve the contents of the file.

    ------------------------------
    Pratap Seetharaman
    DTE Energy
    ------------------------------



  • 4.  RE: restAPI File download

    Maximo Certified
    Posted 07-11-2021 03:17
    Hi Pratap,

    Auto Script runs on the server therefore it gets saved into the server location. 
    There are few things which I can think of:
    1. Write bean class and try to copy the logic of download list button. I am not sure but if you read how maximo is saving file to local directory in the download list bean classes then you might be able to replicate it in Maximo 7.6.1 or above versions using auto script.
    2. Work Centers are client side programming so customizing one of the work center might be a easier solution.
    3. One other option is to put the file in a mapped drive from the auto script. The mapped drive which is accessible from maximo server as well as your local system.

    Thanks,
    Biplab

    ------------------------------
    Biplab Choudhury
    Tata Consultancy Services
    ------------------------------



  • 5.  RE: restAPI File download

    Posted 07-12-2021 09:00
    Thanks Biplab for the response. Will try option 1.

    Thanks,
    Pratap

    ------------------------------
    Pratap Seetharaman
    DTE Energy
    ------------------------------



  • 6.  RE: restAPI File download

    Posted 07-13-2021 12:57
      |   view attached
    Attached is a script that writes a demonstration file to the integration global directory and then uses the intdownload servlet to download the created file.

    Instead of just writing a test file, you could write out the results of your endpoint call.  

    The openUrl method ultimately is being invoked within the same session, so your call should be routed to the same host as the initial call and therefore the file that was created on the host should be available.  This is going to be dependent on your specific clustering rules and affinity settings, but in my environment with limited testing this works.

    Regards,
    Jason

    ------------------------------
    Jason VenHuizen
    Sharptree
    ------------------------------

    Attachment(s)

    js
    filedownload.js   1 KB 1 version


  • 7.  RE: restAPI File download

    Posted 07-13-2021 15:38
    Jason  - Thanks for the response. I was coding along the same line and your script saved me time,  which is exactly how i wanted it to work. Thanks again. 

    Regards,
    Pratap

    ------------------------------
    Pratap Seetharaman
    DTE Energy
    ------------------------------