Closed. This question needs to be more focused。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?更新问题,使其仅通过editing this post专注于一个问题。
                        
                        6个月前关闭。
                                                                                            
                
        
我正在利用Python的simple-salesforce软件包执行批量上传。我看到一些不一致的响应错误,我相信可以通过将'concurrencyMode'更改为'Serial'来解决

我在文档中没有看到该选项。有谁知道是否可以更新源代码以将该参数添加到请求中?我尝试更新api.py和bulk.py中的标头,但没有运气。

谢谢

最佳答案

simple-salesforce批量方法通过发布到https://<salesforce_instance>/services/async/<api_version>/job使用Salesforce Bulk API 1.0。在bulk.py中,作业的创建方式如下:

 def _create_job(self, operation, object_name, external_id_field=None):
        """ Create a bulk job
        Arguments:
        * operation -- Bulk operation to be performed by job
        * object_name -- SF object
        * external_id_field -- unique identifier field for upsert operations
        """

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


这将生成以下XML有效负载:

<jobInfo
   xmlns="http://www.force.com/2009/06/asyncapi/dataload">
 <operation>...</operation>
 <object>...</object>
 <contentType>JSON</contentType>
</jobInfo>


要显式请求串行作业,您需要在请求中添加concurrencyMode元素。 jobInfo片段应为

<jobInfo
   xmlns="http://www.force.com/2009/06/asyncapi/dataload">
 <operation>...</operation>
 <object>...</object>
 <concurrencyMode>Serial</concurrencyMode>
 <contentType>JSON</contentType>
</jobInfo>


更改_create_job以具有以下额外元素:

 def _create_job(self, operation, object_name, external_id_field=None):
        """ Create a serial bulk job
        Arguments:
        * operation -- Bulk operation to be performed by job
        * object_name -- SF object
        * external_id_field -- unique identifier field for upsert operations
        """

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

关于python - Python Simple-Salesforce更改'concurrencyMode',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57960907/

10-12 22:49