I am trying to bulk load a csv file with 11000 records using Python with the simple-salesforce API.
The error that I am running into is that when I try to load the file, I get this message:
{'created': False,
'errors': [{'fields': ['external_field__c'],
'message': "Json Deserialization failed on token 'external_field__c' "
'and has left off in the middle of parsing a row. '
'Will go to end of row to begin parsing the next row',
'statusCode': 'INVALID_FIELD'}]
I am able to load just one record using my code, but anything greater than 1 then I get the JSON Deserialization error. I have validated that the API name in the Object Manager is the same as what I am trying to upload.
This is my code:
from simple_salesforce import Salesforce
from pprint import pprint
import json
import pandas as pd
from pandas import json_normalize
from sfbulk2 import SFBulk2
import requests
import csv
from salesforce_bulk import CsvDictsAdapter
load_data = pd.read_csv('C:\\Users\\BlahBlah\\Desktop\\test_csv4.csv')
load_data = load_data.fillna('')
print(load_data)
bulk_data = []
for row in load_data.itertuples():
d = row._asdict()
del d['Index']
bulk_data.append(d)
sf = Salesforce(username='username', password='password', security_token='token', domain='test')
x = sf.bulk.Account.upsert(bulk_data,batch_size=10000, external_id_field='external_field__c')
pprint(x)
I am thinking that there might be something very simple I could be missing with this code, but I have tried to research this issue for hours without getting anywhere.
Edit Adding "fake" data:
external_ID__c,LastName,FirstName,MiddleName,PersonBirthdate,RecordTypeId,Phone,PersonMailingStreet,PersonMailingCity,PersonMailingState,PersonMailingPostalCode,PeronMailingCountry
9999,SMITH,JOHN,,1970-01-01,XXXXXXXXXXXXXXX,99999999999,123 ANY STREET,ANYTOWN,NY,10001,USA```