我想插入或更新salesforce记录。但是我得到了以下错误:
SeqNo__c"是"202102 - 123";从中指定要更改的记录的id。它似乎不能在SeqNo__c中找到它。
如果有人知道,请告诉我。
这段代码
from simple_salesforce import Salesforce
from datetime import datetime
import os
import json
import gzip
from pytz import timezone
import requests
#strDate = datetime.now().strftime("%Y%m%d")
#strTime = datetime.now().strftime("%H%M%S")
SALESFORCE_USERNAME = '123@gmail.com'
PASSWORD = '12345'
SECURITY_TOKEN = '12345'
# Authentication settings
sf = Salesforce(username=SALESFORCE_USERNAME,
password=PASSWORD,
security_token=SECURITY_TOKEN)
#Try bulk but also error
#data = [{'SeqNo__c': '202102-123', 'NewNO__c': '1'}]
#sf.bulk.Contact.update(data)
sf.Contact.upsert('SeqNo__c/202102-123',{'NewNO__c': '1'})
错误代码Traceback (most recent call last):
File "c:UserstestDocumentssalesforcesf_check.py", line 27, in <module>
sf.Contact.upsert('SeqNo__c/202102-123',{'NewNO__c': '1'})
File "C:UserstestAppDataLocalProgramsPythonPython39libsite-packagessimple_salesforceapi.py", line 694, in upsert
result = self._call_salesforce(
File "C:UserstestAppDataLocalProgramsPythonPython39libsite-packagessimple_salesforceapi.py", line 800, in _call_salesforce
exception_handler(result, self.name)
File "C:UserstestAppDataLocalProgramsPythonPython39libsite-packagessimple_salesforceutil.py", line 68, in exception_handler
raise exc_cls(result.url, result.status_code, name, response_content)
simple_salesforce.exceptions.SalesforceResourceNotFound: Resource Contact Not Found. Response content: [{'errorCode': 'NOT_FOUND', 'message': 'Provided external ID field does not exist or is not accessible: SeqNo__c'}]
PS C:UserstestDocumentssalesforce>
Contact.SeqNo__c
字段是否标记为外部id?字段定义中有一个必须勾选的复选框。你的用户需要有一个配置文件权限,至少可以看到