Macterror
Macterror

Reputation: 431

Salesforce bulk API: How to set a date to null

I am writing some python code to set some dates to null. According to the documentation, anything that needs to be set to null, will have to contain #N/A on the csv its picking up the data from. However this does not seem to work for date fields. I get the following error:

SalesforceMalformedRequest: Malformed request https://na131.salesforce.com/services/async/38.0/job/7504O00000LKUpIQAX/batch/7514O00000SWAzPQAX/result. Response content: {'exceptionCode': 'InvalidBatch', 'exceptionMessage': 'Records not processed'}

I made sure the field shows up as nillable on workbench as well.

How can I set an existing date to null? Any help is appreciated

Upvotes: 1

Views: 1886

Answers (1)

David Reed
David Reed

Reputation: 2759

simple_salesforce does not use the CSV-format Bulk API (even if the underlying data is sourced from a CSV file). See bulk.py:

payload = {
    'operation': operation,
    'object': object_name,
    'contentType': 'JSON'
}

In the JSON version of the Bulk API, fields to be nulled must be set to null in JSON:

To specify a null value in JSON, set the field value to null. For example, "description" : null

Do so in Python by setting the relevant property to None.

Upvotes: 2

Related Questions