I am trying to upload multiple attachments using Bulk API. I am using createBatchFromDir() for creating the Batch & using the sample code provided in the sfdc documentation at the link:-


I have replaced the createBatchesFromCSVFile() method with createBatchFromDir().

I am passing the batchContent parameter as

InputStream batchContent = new FileInputStream("C://Temp//TestUploadCases//Attachments//Upload.csv"); 

Also have set the ContentType param as "ZIP_CSV".

However when I execute the code I am getting the following error:-


[BatchInfo  id=........
 stateMessage='InvalidBatch : Field name not found : Name'

[AsyncApiException exceptionCode='InvalidBatch' exceptionMessage='Records not processed' ]

This error occurs while trying to execute the following line in checkResults() method:-

new CSVReader(connection.getBatchResultStream(job.getId(), b.getId()));

Any help to resolve the above error would be very much appreciated.


  • Thanks. The header contains 3 colmns as:- Name ParentId Body
    – Rahul
    Commented Apr 6, 2015 at 15:40

3 Answers 3


I provided the Zip file path as tmpInpuStream and got the same error by calling:

connection.createBatchWithInputStreamAttachments(jobInfo, tmpInputStream, attachments); 

(Same Error)

Provided the path of manifest file as request.txt by calling:

connection.createBatchWithInputStreamAttachments(jobInfo, tmpInputStream, attachments); 

(Same Error)

After analyzing the Apex Data Loader functionality, I provided the path of manifest file as request.csv and calling: (It worked)

connection.createBatchWithInputStreamAttachments(jobInfo, tmpInputStream, attachments); 

bypassing createCSVFromBatches() method and the Name in Manifest file matching the Key of attachments Map.

Also, the value of attachments Map containing the absolute path of File and Body of manifest file containing the relative path using #.


May be for successful result you need add 'Name' column in your csv. Is it possible to show your csv-file header (column names)?


Please check Field level security and profile settings of the field,and compare with userprofile you are executing this job with

You must log in to answer this question.

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