I would like to create an apex service in salesforce that accepts csv files.

Resolved this issue with the following:

Created a public site which the FileUpload class is added. Since I need to create an unauthenticated endpoint. You can also have the authenticated endpoint via creating connectedApp and setup oauth.

Apex service

global with sharing class FileUpload{

    global static void processFile() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        Blob b = req.requestBody;
        // Add data processing here based from Blob value

Client command:

curl -H 'X-PrettyPrint: 1' -H 'Content-Type: text/csv' --data-binary '@<file absolute path>' '<public site URL>/services/apexrest/api/FileUpload/'

1 Answer 1


Well, you can upload the csv as Content Version, by making a post request using REST api to this particular url "/services/data/v45.0/sobjects/ContentVersion", and have a trigger for Content version object and call your particular class in that trigger to process the csv.

here is the link for your reference

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .