1

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:-

https://www.salesforce.com/us/developer/docs/api_asynch/Content/asynch_api_code_walkthrough.htm.

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:-

BATCH STATUS:

[BatchInfo  id=........
 jobId=.........
 state='Failed'
 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.

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

3 Answers 3

1

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 #.

-1

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

0
-1

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 .