Reputation: 6756
I would like to add batch with csv file to a job in salesforce.com, according to docs. I use the following code to do that, but it does not work (no new objects appear in salesforce):
headers = {
'Content-Type': 'text/csv; charset=UTF-8',
'X-SFDC-Session': client.sessionId
}
(_, host, path, _, _, _) = urlparse("https://%s/services/async/24.0/job/%s/batch" % (instance, job_id))
csv_file = open('test.csv', "rb")
t = csv_file.read()
conn = httplib.HTTPSConnection(host)
conn.request("POST", path, t, headers)
response = conn.getresponse()
rawResponse = response.read()
How can I attach file to request and send it?
Upvotes: 0
Views: 356
Reputation: 19040
the records aren't processed until you update the job status to indicate you've uploaded all the batches in the job. see the quickstart in the docs
Upvotes: 1
Reputation: 33420
The thing with the HTTP protocol, is that it requires some boilerplate to generate an HTTP request with attached binary contents.
Either use the poster lib, either reuse a lower level code snippet as there are plenty.
Upvotes: 1