December 22, 2020

Configure REST Trigger Endpoint to Get CSV Data


In this blog we will see the steps to configure REST Trigger (Source) Endpoint which can receive CSV data as Input from any source system (ex : from WMS System) and do the data processing as require further.


Click to Zoom Out


Lets see the Steps in Detail by doing one end to end POC.

Use case : We will create one Integration that can receive CSV data as Input and then Log the same data using Logger Action. 


Step 1 : Create one App Driven Orchestration Integration 



Knowledge :  πŸ‘€ 
App Driven Orchestration ? : It enables you to create an integration that uses an event or business object to trigger the integration. It is a Multi-step Integration flow invoking applications, integrations and processes triggered by an Application or API.


Step 2 :
Add Rest Trigger Connection type. You can follow this blog to create Rest Trigger Connection. 



  •  Enter any meaningful name and then click Next
  •  configure this window as suggested below :
    • *what is this endpoint's relative Resource URI ? : /csvdata (you can enter any meaningful URI)
    • *What action do you want to perform on this endpoint : POST
    • Select configure a request payload for the response and then click Next
  • Now configure the Request Payload as suggested below
    • Select the request payload format : Binary
    • What is the media-type of Response Body ? (Content Type Header) : Select Other Media Type 
    • ︖ Media Type. : Enter text/plain
  • Rest Endpoint configuration completed. Click Done

Step 3 : Now in this step lets configure one Stage File Action to read the received csv file data.

  • Add Stage File activity



Knowledge :  πŸ‘€ 
Stage File Activity ? : It provide access to the Integration Cloud local file system server.  Using this activity you can Read,Write,List,Zip,Unzip etc. files that are already present in the local file server. You can use any of these operation by providing the File Name and its Directory Path.


  • Enter any meaning full name and click Next


  • Configure the stage File Action parameter as suggested below
    • *Choose the Stage File Operation : Read Entire File
    •  Configure File Reference : Select Yes
    • *Specify the File Reference  : Click Edit (Pencil icon) and then drag and drop *streamRefernece into Expression box (as shown in below image). click save and and click Exit Expression Builder

  •  Select Sample delimited document (e.g. CSV) to define the structure of the file contents. Then click Next

  • Define the structure of the file contents by selecting below Delimitated Sample File. After selecting file configure the other options as suggested below :
          Download Sample File

    • Enter  the record name : Student (you can give any meaning ful name)
    • Enter the Record set name : StudentsDetail (You can any meaningful name )
    • Select the Field Delimiter : Comma(,)
    • Optionally Enclosed by  : "
    • Terminated By : ${eol}
              Click Next 


  • Stage File Action configuration completed. Click Done.


Step 4 :Now lets add one Logger to log the received CSV data.


Knowledge :  πŸ‘€ 
Logger ? : It Enables you to add log messages to the activity stream and diagnostic logs.

  • Search for Logger action and add it in flow


 

  • Enter any meaningful name and then click Create 

  • Configure Logger option will get open , Select Log : Always and then click edit (pencil icon ) to map *Logger Message 

  • Drag and drop *StudentDetail tag from left hand side(Source side ) inside Epression box and then click validate and close

  • Click Validate and close 

Step 4 : Now enable the Tracking by clicking on right hand side hamburger sign and then click Tracking 


  • Drag and Drop *streamReference in Primary Tracking Field.You can select another also as per your requirement.
Click Save 

Knowledge :  πŸ‘€ 
Assigning Business Identifiers for Tracking Fields ? : Business identifiers enable you to track payload fields in messages during runtime.You must assign business identifiers before you can activate an integration.

  • Integration is ready to test. Save the integration and Activate it.




#Testing of Integration 

Now lets test the integration by passing some sample csv data as input of this integration and lets see the data are getting generated in Log or not.


 [ Note : -- If you want to test this integration by getting it trigger from any Source System (Like WMS System ). For that you can share the endpoint point url of this integration with WMS system and getting it configured in that system. After that that system can hit this integration by sending some CSV data. ]

  • Click on Run button
  • Click Test 
  • Pass the below sample CSV data and click Test
Name,Roll
Shyam,01
Rashmi,02
Raghu,03
Rajesh,04
Satya,05


  • You can see the input csv data in Log (as shown in below image)
  • If you want to see the CSV data in XML check the Read Response Payload.


Completed. This way we can configure REST Trigger Endpoint to receive CSV data from Source System(Like WMS)


No comments:

If you have any doubts, Please let me know.