felixlindstrom / python-salesforce-api Goto Github PK
View Code? Open in Web Editor NEWPython Salesforce API wrapper made easy
License: MIT License
Python Salesforce API wrapper made easy
License: MIT License
I am currently evaluating the module in a monitoring project.
It seems that in login.py a debug print statement was forgotten in the code, so every time a SOAP authentication occurs, the call to soap() results in an erroneous print statement that messes up the output of the calling program.
I'll submit a PR to fix this.
it pulls it from const.API_VERSION but it should be a parameter that can be passed in when constructing the salesforce api client
I was using salesforce-api 0.1.35 I am getting an error in importing
from salesforce_api.models.retrieve import Type
An exception has occurred: ImportError
cannot import name 'Type' from 'salesforce_api.models.retrieve' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/salesforce_api/models/retrieve.py)
python-salesforce-api/salesforce_api/login.py
Line 101 in 37ed67b
This creates a bug with reverse proxies or firewalled environments that specifically whitelist certain URLs.
Using the existing instance_url
to make the call to plain_access_token(instance_url=instance_url,...)
would fix it.
I need to switch a user account for an account record, but most login methods require a combination of username and a password, and I don't have any of those, the only things I have is the consumer key and the consumer secret, is there a way to login just with those attributes?
Hi,
First of all thanks a lot for providing such a nice client and making one aspect of the salesforce API simple.
While using the client, the following line is outputting logs that cannot be easily disabled in the logging config. The root logger is being used which means in order to disable this log line, the root logger itself has to switch from INFO
to a higher filter.
Would it be possible to use a logger specific to the package (e.g "salesforce_api") or reduce this log level to debug
?
Cheers
Destination URL not reset. The URL returned from login must be set
Might related to
https://developer.salesforce.com/forums/?id=906F00000008rtEIAQ
I am using auth_token as the way to auth
query: client.sobjects.query("SELECT Id, FirstName, LastName FROM Contact WHERE FirstName='Felix'")
hi,
i am using the library. however in my application, i am already getting the csv files. so step for converting csv to json and back to csv is not useful.
is there option to just provide csv name? Here, obviously, it will work only for max-size. we may have to develop function for 'csv-within-limit' and also a splitting.
also, if list of json is provided, does the library handles splitting of records to get the csv only for max allowed size?
regards,
amit
I think many uses have this on their mind:
Why is python-salesforce-api better than simple_salesforce?
It would be very kind if you could answer this question in the README.
Thank you.
Seems like something is wrong with bulk jobs. InProgress jobs get returned as errors.
Starting update
'InProgress' is not a valid JOB_STATE
ValueError: 'InProgress' is not a valid JOB_STATE
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "sfdc.py", line 131, in <module>
raise e
File "sfdc.py", line 126, in <module>
resp = sf.bulk.update('Contact', upd)
File "/Users/mxk/opt/anaconda3/lib/python3.8/site-packages/salesforce_api/services/bulk/v2.py", line 44, in update
return self._execute_operation(OPERATION.UPDATE, object_name, entries)
File "/Users/mxk/opt/anaconda3/lib/python3.8/site-packages/salesforce_api/services/bulk/v2.py", line 58, in _execute_operation
return job.wait()
File "/Users/mxk/opt/anaconda3/lib/python3.8/site-packages/salesforce_api/services/bulk/v2.py", line 115, in wait
while not self.is_done():
File "/Users/mxk/opt/anaconda3/lib/python3.8/site-packages/salesforce_api/services/bulk/v2.py", line 98, in is_done
return self.get_state() in JOB_STATES_DONE
File "/Users/mxk/opt/anaconda3/lib/python3.8/site-packages/salesforce_api/services/bulk/v2.py", line 95, in get_state
return JOB_STATE(self.info().get('state'))
File "/Users/mxk/opt/anaconda3/lib/python3.8/enum.py", line 309, in __call__
return cls.__new__(cls, value)
File "/Users/mxk/opt/anaconda3/lib/python3.8/enum.py", line 600, in __new__
raise exc
File "/Users/mxk/opt/anaconda3/lib/python3.8/enum.py", line 584, in __new__
result = cls._missing_(value)
File "/Users/mxk/opt/anaconda3/lib/python3.8/enum.py", line 613, in _missing_
raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 'InProgress' is not a valid JOB_STATE
Hi @felixlindstrom
First thank you for sharing this, saved me a lot of time !
It seems there is an issue in https://github.com/felixlindstrom/python-salesforce-api#bulk-update documentation since the update key
is not specified.
IMO it should be something like
client.bulk.update('Contact', [
{'LastName': 'Lindstrom', 'Email': '[email protected]', 'MyId__c': 1},
{'LastName': 'Something else', 'Email': '[email protected]', 'MyId__c': 2}
], external_id_field='MyId__c')
or
client.bulk.update('Contact', ['0031l000007rU5rAAE', '0031l000007rU5sAAE'], [
{'LastName': 'Lindstrom', 'Email': '[email protected]'},
{'LastName': 'Something else', 'Email': '[email protected]'}
])
Could you please take a look ?
Best regards
There is a workaround, is you just use the password in the password_and_security_token parameter when constructing the Salesforce Client
Salesforce requires the uploaded data to be encoded as (or at least compatible with) UTF-8. (https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/datafiles_prepare_csv.htm, fourth bullet point from the top). Though, in practice, upload jobs with higher-code-point characters fail in Python before the ingest request can be sent to Salesforce.
The bulk
client does not encode the CSV data, which remains as type str
until a lower-level package must make an encoding decision. The low-level Python http
library sees a str
object and tries to make a bytes
out of it by encoding to the HTTP-default, ISO-8859-1. But I pass it data that is not compatible with that encoding, so it raises a UnicodeEncodeError
.
Here is a contrived example of something that should work but doesn't:
salesforce.bulk.insert('Contact', [
{'FirstName': 'Σόλων', 'LastName': 'Lawgiver', 'AccountID': '000000000000000'},
])
As a workaround, in the codebase I'm working in, I've monkey-patched salesforce_api.services.bulk.v2.Job._prepare_data
such that it calls encode('utf-8')
and returns bytes
. I've not submitted a PR to change this function, as there's a stack of calling functions that all expect str
, so encoding then and there may not be the desired long-term fix. But the patch works for now.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.