In this blog we are going to show you, how to use Oracle Integration cloud  FTP adapter to write files on the  SFTP location.

In my previous blog, I have explained how to create SFTP connection with the help of FTP adapter in Oracle Integration Cloud (OIC).

Use Case: In the blog, I’ll develop a REST service that will accept the below json in request, create a .csv file and upload the same on SFTP location.

{
“employeeId”:”ABC@123″,
“firstName”:”Ankur”,
“lastName”:”Jain”,
“Qualification”:”MCA”,
“Designation”:”Sr. Manager”
}

This Use case requires only simple 4 steps to complete:

  1. Create REST connection
  2. Create FTP connection
  3. Create an Integration
  4. Activate the Integration
Let’s go step by step
  1. Create REST connection: The REST connection will be used to create the REST API. Refer the blog to create the REST connection.
  2. Create FTP connection: FTP connection allow you to interact with SFTP. We have already showcased the same in one of my blog. Please check it out before moving forward.
  3. Create an Integration: Follow below steps to create an App Driven Orchestration Integration
  • Login into OIC console and navigate to the Integrations -> Integrations
  • From the top right corner click on Create button
  • Select App Driven Orchestration pattern from the dialog box

Write file using FTP adapter in OIC

  • Enter Below information and click on Create button
    • Enter Integration Name in What do you want to call your integration text box
    • An Identifier would be picked up automatically from Integration name however you can update it
    • Let the Version as it is
    • Enter the description in What does this integration do box
    • Leave the package box as it is
Write file using FTP adapter in OIC
  • Select inline or Drop the the REST connection on the canvas

Write file using FTP adapter in OIC

  • Enter “Write File” in the “What do you want to call your endpoint” input text and click Next button.
  • On the next screen, Enter below information and Click Next
    • What is the endpoint’s relative resource URI?: Enter /write
    • What action do you want to perform on the endpoint: Select POST
    • Select Configure a request payload for this endpoint checkbox- This option allows us to assign payload in the next step

Write file using FTP adapter in OIC

  • Select JSON Sample from the Select the request payload fromat drop down button.  Select inline link and enter the sample JSON payload as mentioned under Use Case section above
Write file using FTP adapter in OIC
  • Click Next and finish the wizard
  • Click Invokes from right, Select TEST_FTP_Conn, drag and drop the TEST_FTP_Conn just below the REST adapter

Write file using FTP adapter in OIC

  • Enter Name and optionally description. Click Next button

Write file using FTP adapter in OIC

  • Enter below information and click Next button
      • Select Operation: In our case select Write File
      • Select a Transfer Mode: Select ASCII
      • Specify an Output Directory: Enter directory location where the file to be written
      • Specify a File Name Pattern: Either enter any hard coded file name or File Name pattern. In our case, I will enter a File name pattern as test_%yyMMddHHmmss%.csv
      • Append to Existing File: If this option is selected, the data will be appended to the existing file if already exist with same name.

Write file using FTP adapter in OIC

  • Select the below options and click on the Next button
    • Do you want to sepcify the structure for the contents of the file: Select Yes
    • Which one of the following choices would be used to describe the structure of the file contents: Select Sample delimeted document (e.g CSV)

Write file using FTP adapter in OIC

  • From the next screen, enter below information and Click Next button
    • Select the Delimited Data File: Select the comma separated file from your local machine. Please download sample file from here
    • Enter the Record Name: Enter Employees
    • Enter the Recordset Name: Enter Employee
    • Select the Field Delimiter: Select Comma(,) as a delimiter
    • Character Set: This allows us to select character set
    • Optionally Enclosed By: Let it be
    • The below table allows us to select which field to keep optional and which would be mandatory. Atleast one column must be mandatory.

Write file using FTP adapter in OIC

  • Review summary and finish the wizard
  • Click on Map to CreateFile mapper and click edit button
  • Mapper will allows us to map source and target fileds.
  • In order to create the headers in the csv file, expand Employee node from Target and click on Employees node and select “Repeat Node“. This action will add new Employees node in the target mapper.

Write file using FTP adapter in OIC

  • Expand the (1 of 2) Employees node
  • Right click on the EmployeeId and click on the Create Target Node. This action will open the Expression box on the bottom of the screen. Click Switch to Developer View icon

Write file using FTP adapter in OIC

  • Enter the hardocoded string as ‘EmployeeId‘ in single quotes and click on the Save icon.
  • Repeate above two steps for rest of the fields (FirstName, LastName, Qualification and Designation)
  • Now expand the (2 of 2) Employees node. Map the source and target fields as per below:

WriteFile/request-wrapper/employeeId —> CreateFile/Employee/(2 of 2) Employees/EmployeeId

WriteFile/request-wrapper/firstName —> CreateFile/Employee/(2 of 2) Employees/FirstName

WriteFile/request-wrapper/lastName —> CreateFile/Employee/(2 of 2) Employees/LastName

WriteFile/request-wrapper/Qualification —> CreateFile/Employee/(2 of 2) Employees/Qualification

WriteFile/request-wrapper/Designation —> CreateFile/Employee/(2 of 2) Employees/Designation

Write file using FTP adapter in OIC

  • Validate and Close the mapper
  • Select Actions icon from the top righ corner and click on Tracking. Integration can’t be activated without this step. Basically this allows us to track the message with configured parameter. In our case we will select employeeId field.

Write file using FTP adapter in OIC

  • Drag & Drop the employeeId from left panel to first row in Tracking Field and click Done button
  • Click Save and Close button from upper right corner
Now the integration is completed and this is the time to activate the integration.
4. Activate Integration
  • Click on Activate icon to activate the integration.

  • Select Enable tracking and Include payload check boxes. This option is useful if we want to see payload in the logs. Click Activate button

Write file using FTP adapter in OIC

  • This step will deploy the integration on the OIC server.
5. Test the REST service
Let’s try to test the integration now via the inbuilt testing tool in OIC. Hover the Integration, click on the Run icon and select Test 
  • Click on the Body and enter the JSON payload to test. Click on the Test button

  • Open FTP location and see the file should be created there.

You can view my YouTube video also.