Enter your keyword

post

Download CSV file from REST service Response Content: Oracle Integration Cloud

There are certain REST Services which provides the CSV file as part of the response and needs to consume in the Integration Cloud. In the article, we’ll demonstrate how to catch the CSV file from REST service response leveraging Integration Cloud REST Adapter.

In the below Screenshot, when we hit the REST Service in the browser URL box then it downloads a CSV file.

Let’s go step by step and see how to achieve this use case

  • Create a Scheduler with the name(DownlaodCSV)
  • Drop the REST service connection and configure the below option on the initial page
    • What do you want to call your endpoint: DownloadFile
    • What is the endpoint’s relative resource URI?: /{path}
    • What action does the endpoint perform: GET
    • Check the checkbox Add and review parameters for this endpoint
    • Check the checkbox Configure this endpoint to receive the response 
  • Click the Next button on the next screen
  • Select Raw Radio button of the Select the response payload format. Click the Next button and finish the wizard
  • Open the edit mapper and configure the template parameter as per the REST service
  • Drop the Stage action just below the REST adapter and enter “WriteToStage” in What do you want to call your action? text box
  • Enter the below information and select the Next button
    • Choose Stage File Operation: Write File
    • Specify the File Name: test.csv
    • Specify the Output Directory: /stage
  • Select the “Select an existing schema from the File system” radio button
  • Past the below schema in notepad file, save it and select using the “Choose File” option
<?xml version = ‘1.0’ encoding = ‘UTF-8’?>
<schema targetNamespace=”http://xmlns.oracle.com/pcbpel/adapter/opaque/”
            xmlns=”http://www.w3.org/2001/XMLSchema” >
      <element name=”opaqueElement” type=”base64Binary” />
</schema>
  • Edit the “WriteToStage” mapper, click on the “opaqueElement“, drop the “encodeReferenceToBase64()” function and then drop the “streamReference” element from left panel on the function “encodeReferenceToBase64()”
  • Drop another “Stage” activity, and enter “ReadFromStage” in What do you want to call your action? text box
  • Enter the below information and select the Next button
    • Choose Stage File Operation: Read Entire File
    • Specify the File Name: test.csv
    • Specify the Output Directory: /stage
  • Select “Create a new schema from a CSV file” Radio button and click the Next button
  • Configure below option and click the Next button
    • Select a new Delimited Data File: Choose the sample CSV file which must be of the same type as REST service response
    • Enter the Record Name: Record
    • Enter the Recordset Name: Records
  • Finish the wizard. Integration is completed and ready to test now. Save and Close the integration and simply Submit
Open the “DownloadCSV” instance and open the activity stream. The CSV data should be printed into the payload section

Some Toughts (6)

  1. added on 29 Apr, 2019
    Reply

    how can we make the JSON file complaint to swagger 2.0

  2. added on 16 Jul, 2019
    Reply

    what is the template parameter we have to pass here?

  3. added on 16 Jul, 2019
    Reply

    Template parameter is just the path of file from where the file will be downloaded.

  4. gabriel
    added on 3 Jan, 2020
    Reply

    I am following your step but at the rest response i am getting empty value as the file reference. Did you ever faced this?

    • added on 4 Jan, 2020
      Reply

      No, I have never faced such issue. Would be happy to resolve your issue. Please share your iar file.

Leave a Reply

Your email address will not be published.