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