1

After a Bulk API upsert, I can inspect the batch after the fact and see that my 4 records failed.

{
'apexProcessingTime': '0',
'apiActiveProcessingTime': '1',
'createdDate': '2017-07-21T15:33:47.000Z',
'id': '...',
'jobId': '...',
'numberRecordsFailed': '4',    # This is non-zero, so something went wrong
'numberRecordsProcessed': '4',
'state': 'Completed',
'systemModstamp': '2017-07-21T15:33:47.000Z',
'totalProcessingTime': '21',
}

Is there any way to get the reason they failed? An error message of any sort, so that I may correct whatever is wrong.

(For the curious, I'm using the salesforce-bulk Python library, and used the batch_status function to get the above print out.)

2
  • 1
    Did you goto the bulk jobs ui in SF and download the error log. I believe the info is there. I am pretty sure you can get this via API as well but do not know syntax of the top of my head
    – Eric
    Jul 21, 2017 at 15:49
  • Found the result.csv in the Salesforce dashboard (Setup -> Environments -> Jobs -> Bulk Data Load Jobs, or just searching "Bulk Data Load Jobs in the left-side search bar on Setup page"). Thanks! Separately, also wondering how to do with API, will edit the Q
    – tscizzle
    Jul 21, 2017 at 16:22

1 Answer 1

2

Using the salesforce-bulk Python library I mentioned, see this file and find def get_batch_results.

If you're not in Python (which is quite likely), see how that function is defined. It uses a URI of the form:

endpoint + "/job/<job_id>/batch/<batch_id>/result"

where endpoint is the base Salesforce API URL you've been using. And insert your job_id and batch_id you get as direct response of the bulk request you want to observe the results for.

Note that they have handling for different response content types:

if resp.headers['Content-Type'] == 'application/json':
    ...
elif resp.headers['Content-Type'] == 'text/csv':
    ...
elif resp.headers['Content-Type'] == 'application/xml':
    ....

You must log in to answer this question.

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