API Connect

 View Only
  • 1.  How to call pdf set in temporary folder inside Datapower filesystems

    Posted Mon July 11, 2022 07:43 AM

    Hi all,

    I have created a Gatewayscript inside local:/// which decodes a base64 encoded pdf sent thorugh from API Connect and creates the pdf inside temporary folder in the filesystems.

    I now want to call the pdf from temporary folder to APIC and set it to the response body of the API. Any ideas on how to go about this. 

    i am getting the following error:

    {
    "httpCode": "500",
    "httpMessage": "Internal Server Error",
    "moreInformation": "The 'temporary:///applicationTest.pdf' script file is not encoded in UTF-8. Invalid character at line 2, position 2."
    }.



    ------------------------------
    Samuel Pius
    ------------------------------


  • 2.  RE: How to call pdf set in temporary folder inside Datapower filesystems

    Posted Tue July 12, 2022 01:21 AM
    Hi,

    You can try ('urlopen') module, I am pretty sure this should work for you.
    https://www.ibm.com/docs/en/datapower-gateway/10.0.x?topic=apis-urlopen-module

    ------------------------------
    Jayprakash Yadav
    ------------------------------



  • 3.  RE: How to call pdf set in temporary folder inside Datapower filesystems

    Posted Tue July 12, 2022 01:33 AM

    Hi Jayprakash,

    I tried using this but it says the data used to transfer must be UTF-8 encoded. 

    i'll once on a .txt file and let you know



    ------------------------------
    Samuel Pius
    ------------------------------



  • 4.  RE: How to call pdf set in temporary folder inside Datapower filesystems

    Posted Tue August 30, 2022 09:58 AM
    @Samuel Pius - any update since your last response? ​

    ------------------------------
    Jina K
    ------------------------------



  • 5.  RE: How to call pdf set in temporary folder inside Datapower filesystems

    Posted Thu November 10, 2022 07:41 AM
    Hi All, 

    me too also trying to download pdf file which is stored in the Data Power file manager  or FTP server, currently we tried Data Power local folder to get the pdf file and we able to download it as .file format but we need .pdf how to do this? please help me.

    ------------------------------
    kandula nagababu
    ------------------------------



  • 6.  RE: How to call pdf set in temporary folder inside Datapower filesystems

    Posted Fri November 11, 2022 12:33 AM
    Hi, 
    You create MPGW retrieving a file with dynamic input file nane, post that create Api to call that Mpgw with required file name. 
    This will work.
    Regards,
    Jayprakash Yadav


    ------------------------------
    Jayprakash Yadav
    ------------------------------



  • 7.  RE: How to call pdf set in temporary folder inside Datapower filesystems

    Posted Sat November 12, 2022 11:35 PM
    Hi Jayprakash,

    We already did same thing but we able to download .file format not .pdf format.

    ------------------------------
    kandula nagababu
    ------------------------------



  • 8.  RE: How to call pdf set in temporary folder inside Datapower filesystems

    Posted Fri November 11, 2022 12:06 AM

    Getting a pdf file from the temporary or local file storage by using the fsmodule is not possile because all the files gets UTF-8 encoded when going in and out of datapower. 

    I think we need to look into it more to find a work around. 



    ------------------------------
    Samuel Pius
    ------------------------------



  • 9.  RE: How to call pdf set in temporary folder inside Datapower filesystems

    Posted Tue November 15, 2022 11:45 AM

    Hi Samuel,

    Have you tried a urlopen.open for the local file and assuming the file is found (HTTP 200) you can then use response.readAsBuffer to read the data and set it into context, for example, message.body.  The buffer returned by readAsBuffer is exactly what was read, so as long as you don't attempt to change it using a toString() function (which would use utf-8 encoding) you should be fine.  Don't forget to also update message.headers.content-type to application/pdf to match the content type of the payload.

    Regards,

    Steve



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------