function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Manfred LinznerManfred Linzner 

Bulk API: InvalidSessionId (Unable to find session id)

I'm planning to use the Bulk API for a project on Google App Engine. I've started writing some simple test code to create two Tasks using the Bulk API via the Python [salesforce-bulk-api](https://github.com/safarijv/salesforce-bulk-api) library:
from salesforce_bulk_api import SalesforceBulkJob

header = ['WhoId', 'Subject']
messages = [('[...]', 'Test Task 1'),
            ('[...]', 'Test Task 2')]

os.environ['SALESFORCE_INSTANCE'] = '[...]'
os.environ['SALESFORCE_SECURITY_TOKEN'] = access_token

job = SalesforceBulkJob('insert', 'Task')
job.upload(
    header,
    messages
)

results = job.results()
for r in results:
   print('Result ' + str(r))

Executing this code locally works as expected and the two Tasks appear in Salesforce. But running the code on Google App Engine, it fails. The job / batch details are:
<error xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<script/>
<exceptionCode>InvalidSessionId</exceptionCode>
<exceptionMessage>Unable to find session id</exceptionMessage>
</error>

From what I see in the documentation, session ID needs to be sent via header field `X-SFDC-Session` each time. I've checked that and it is set when executing locally as well as via Google App Engine. Headers looking like this:
{ 'Content-Length': '183',
  'Accept-Encoding': 'gzip, deflate',
  'Accept': '*/*',
  'User-Agent': 'python-requests/2.9.1',
  'X-SFDC-Session': u'00D2[...]vBmM',
  'Connection': 'keep-alive',
  'Content-Type': u'application/xml; charset=UTF-8'}

Anyone having tips how to debug / resolve this issue? Thanks!

– Manfred
NagendraNagendra (Salesforce Developers) 
Hi Manfred,

Please check with below post from stack overflow community with similar issue. Regards,
Nagendra.P
Manfred LinznerManfred Linzner
Thanks Nagendra, in fact this is my question 😉