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
Stephen LoughinStephen Loughin 

salesforce_bulk insert fails but bulk query succeeds?

I can read using bulk.create_query_job, but I can't write back to Product2 with bulk.create_insert_job
bulk = SalesforceBulk(sessionId=self.access_token, host=urlparse(self.instance_url).hostname) 
job = bulk.create_insert_job(object, contentType='CSV')  # fails on this line
reader = csv.DictReader(open(csv_file)) 
items = [] 
for row in reader: 
   items.append(row) 
csv_iter = CsvDictsAdapter(iter(items)) 
batch = bulk.post_bulk_batch(job, csv_iter) 
bulk.wait_for_batch(job, batch) 
bulk.close_job(job)


The object I'm passing is 'Product2' and I can use the same SalesforceBulk object to successfully perform a bulk query on Product2 using bulk.create_query_job.  This code fails on create_insert_job with the following response:
[400] Bulk API HTTP Error: InvalidJob - No create access for object:Product2
Is this a permissions issue?  I am using an admin account.
AnudeepAnudeep (Salesforce Developers) 
Can you check if the user running this code has access to Product2 using the below SOQL?
 
SELECT RecordId, HasReadAccess, HasTransferAccess, MaxAccessLevel
     FROM UserRecordAccess
     WHERE UserId = [single ID]
     AND RecordId = [single ID]      //or Record IN [list of IDs]

 
AnudeepAnudeep (Salesforce Developers) 
Please use the userId visible in the debug logs