+ Start a Discussion
Nihar SharmaNihar Sharma 

Importing Data in salesforce from external system using .csv file with FTP server

Dear All,

Here i have the requirement to use FTP server in salesforce..

-- we have one external system and data inserted into it day by day
-- after that at the end of the day one file(.csv) automatically generated to that external system
-- How can i access of that file(.csv) from external system in salesforce using FTP server
-- after having that file's data i need to insert that data automatically(scheduled) in salesforce which is coming from external system

How can i achieve this ?

Please suggest the way..

Thanks
-Nihar
NagendraNagendra (Salesforce Developers) 
Hi Nihar,

1) You need proxy to access that file from salesforce by HttpRequest.

2) You can create scheduled job to check if there are unprocessed files by request, download that file, parse via apex and perform DML based on file content. 

Give a try with the above suggestions which should help you to accelerate with the above requirement.

Mark this as solved if it's resolved.

Best Regards,
Nagendra.P
Nihar SharmaNihar Sharma
Nagendra,

Thanks.. i will go through your valuable suggestion...

-Nihar
JeffreyStevensJeffreyStevens
Ya - there is no direct access to ftp from Apex.
Nihar SharmaNihar Sharma
Hi Nagendra,

Can you please tell me how to get the proxy access of that file..

i am going to refer this HttpRequest Class...

Sample--
public class AuthCallout {
 
   public void basicAuthCallout(){
     HttpRequest req = new HttpRequest();
     req.setEndpoint('http://www.yahoo.com');
     req.setMethod('GET');
     
     // Specify the required user name and password to access the endpoint
     // As well as the header and header information
 
     String username = 'myname';
     String password = 'mypwd';
  
     Blob headerValue = Blob.valueOf(username + ':' + password);
     String authorizationHeader = 'BASIC ' +
     EncodingUtil.base64Encode(headerValue);
     req.setHeader('Authorization', authorizationHeader);
   
     // Create a new http object to send the request object
     // A response object is generated as a result of the request  
  
     Http http = new Http();
     HTTPResponse res = http.send(req);
     System.debug(res.getBody());
   }
}

tell me where i need change and get that file and scheduled..

Thanks
-Nihar
Shashank Gupta 96Shashank Gupta 96
Hi Nihar,
Did you find the solution? I am having the same requirement.
David_GardelDavid_Gardel
One of the possible way to import .csv files from FTP server to Salesforce is to use Skyvia (https://skyvia.com/data-integration/integrate-salesforce-ftp). It`s a no-coding data integration platform which requires minimal configuration. Jobs can be run manually or scheduled for automatic execution.
Adarsh.SharmaAdarsh.Sharma
You can use below FTP API to integrate FTP server with Salesforce.

We have implemented a REST API which allow to directly communicate with an FTP server. This FTP API is designed for people who need to perform actions like DOWNLOAD, UPLOAD, DELETE and TRANSFER on the FTP server using REST API’s.

FTP API: https://ftp-api.herokuapp.com/
Blog Post: https://medium.com/@adarshsharma.jaipur/how-to-use-ftp-server-using-rest-api-8d1b3f88de0

If your problem have resolve, then mark this solution as a best answer and let me know if you need any other information.