Skip to Content

SAP PI/PO- REST to File - Download file from URL which comes in a field

Hello Experts,

I am on PO 7.5 and working on a REST to File scenario.

Requirement: I need to download a file from a URL .The URL is sent in a field through the REST Call. See below example.

Example:

<Record>

FileName> TestFile1.pdf

URL>www.test.com/TestFile1.pdf

</Record>

<Record>

FileName> TestFile2.pdf

URL> www.test.com/TestFile2.pdf

</Record>

Desired Result: Download the 2 files (TestFile1.pdf and TestFile2.pdf) from the URL's from the URL field and drop it off in an FTP/SFTP server.

I am not a java expert/or an expert with module configuration. Can we do this using an UDF in the graphical mapping.

I see the support attachments option in the REST sender attachment. I am not sure if that is helpful for my scenario.

I checked all the blogs and I was not able to find one that suits my requirement.

Can please you guide me through the configuration process.

Thanks,

Chan

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Mar 19 at 05:19 PM
    Hello,

    I recently created a post explaining how to download a file from amazon, it seems to be a scenario close to what you presented.

    Or try using the FormatConversionBean module adapter that makes encoded/decoded files ... https://blogs.sap.com/2015/03/25/formatconversionbean-one-bean-to-rule-them-all/

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 16 at 07:13 PM

    Hello Har` Chan,
    As your source XML message contains multiple records, so the link to download the files will be multiple and dynamic.

    For a static url, you can get the files using a GET operation of the REST adapter.
    Or you can also implement SOAP-AXIS , where you can use the TASK(Axis) protocol and the HTTPGetter class as connection parameter.You also need to use the parameter - enableREST as true.

    But your source XML has multiple links, so I would say you can create a Java class with a method to get the file from url and save it in a string.

    In your Java mapping method you can pass the number of records and that many times you can all the method to get the files.

    you can call this Java method in your mapping to get all the files and append to a single file. Then you can use a 2nd step mapping to split the entire xml into multiple messages and can produce multiple files at target.
    Though the above design is not a efficient one. In this way it will be hard to capture the each of the source file name. But you can still populate this using Dynamic configuration UDF.

    Moreover, you have to download pdf files which is a binary non-xml file. So it will be too complex with the above approach

    Thanks

    Sugata

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 19 at 02:09 AM

    Was it able to help you?

    Add comment
    10|10000 characters needed characters exceeded

  • May 03 at 09:47 PM

    Thank you all for your valuable inputs.

    Alexander's blog helped me solve the requirement.

    Add comment
    10|10000 characters needed characters exceeded