How To Get Data From The FTP Server to Salesforce

Salesforce provides various ways to import data from external systems. In addition to using various services, we can also rely on third-party services or create our own custom solution for data retrieval.

However, importing data from a remote FTP server can be challenging because Salesforce does not support an FTP server to be set as an endpoint in Remote Site Setting so we have to use an external service in this case.

To overcome this challenge, there are multiple options available to us.

  • One way is to use a third-party service that provides FTP functionality.
  • Another way is to develop a custom solution using FTP API. This allows us to establish a secure connection between Salesforce and the remote FTP server, and transfer data in a structured manner.

    In this article, we will focus on providing a step-by-step guide on how to use FTP API to import data from a remote server.

By the end of this guide, you should have a clear understanding of how to use FTP API to import data and be able to apply this knowledge to your own projects. Lets’s begin!

Pre-Requisites for Implementing this solution

Here are the things you will need to setup:

  • An FTP hosting service to create an FTP server from which you can connect and upload/download your files.

In this demo, we are using Infinity Free hosting service.

In this, we have to just create an account and host an FTP service

  • Now when you have an FTP service you have to interact with your server. For that, you have to use an FTP client. In this case, we will be using FileZilla as our FTP client.

You can download the FileZilla FTP client from here download link. After downloading the FileZilla client you can connect with your server easily from here.

Put the details you got from the Infinity Free FTP details page.

After connecting your FileZilla Client will show your FTP details and its files. From where you upload files to your server.

After doing this setup you can start building your LWC app in which you can get data and then insert that data into your Salesforce org.

We are using the FTP-API download file service so for that we have configured these parameters.

Building LWC APP

Now Coming to LWC App. We will be implementing the solution we come up with using FTP API.

In this case, we are getting a CSV file from our FTP server and inserting it into the Account object.

Apex callout to download files with API.

JavaScript :

HTML :

Apex class to insert accounts:

js-meta.xml

You can use this code with your FTP username and password and deploy it to see an LWC component like this:

The Upload Files is a lightning input that is set to take a CSV from local storage.

In the lower section, the user can enter the file name which has to be downloaded from the FTP server. After getting data from the CSV it will be displayed in a data table like:

After verifying the data user can press “Confirm Upload” to finally insert records in your Account object.

Conclusion:

In conclusion, FTP API can be a useful tool to import data from a remote server to Salesforce. With the proper setup and configuration, it allows for a secure and structured transfer of data.

By following the steps outlined in this guide, you should be able to use FTP API to import data from your own FTP server and apply this knowledge to your own projects.

Be sure to try out the solution and share your experiences with our development team at HIC Global Solutions. Happy Coding!

Our Location worldwide
India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203117884
SR Tower 2nd Floor Hydel Gate Haldwani Uttarakhand 263126 +91-5946359996
USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada
HIC Global Solutions INC
43 Lafferty Lane, Richmond Hill, L4C 3N8, CA +1(262) 310-7818