We have a Django website that interacts with Salesforce custom object named Temp Contact (API: Temp_Contact__c). When I try to login to website, I receive this error in the terminal-
AttributeError: 'HttpResponse' object has no attribute 'query'
But my colleagues are able to login/signup without this error. Only on my system this issue occurs. We are using simple-salesforce==0.73.0 package for integration. I have this package installed in my machine. The line of code that causes the error-
sf1 = salesforceconnection()
sf21 = sf1.query("SELECT Id, Name, Temp_Contact_LastName__c, Temp_Contact_Password__c, Temp_Contact_Active__c, Temp_Contact_Mobile__c, Temp_Contact_Head__c FROM Temp_Contact__c WHERE Temp_Contact_Email__c ='{0}'".format(uname))
The salesforceconnection-
#Used to establish connection with Salesforce NPSP
def salesforceconnection():
try:
sf = Salesforce(instance_url='https://test.salesforce.com', session_id='')
sfconnect = Salesforce(username='[email protected]',
password='qwerty@1234',
security_token='tst3savjIG1DpLMhb9ahWR3R',sandbox=True)
except:
return HttpResponse('Something went wrong. Please try after sometime')
return sfconnect
I put sf1 in print statement and I see that sf1 returns status_code=200. The complete error flow-
SF1=<HttpResponse status_code=200, "text/html; charset=utf-8">
Internal Server Error: /happy/loginpage.html Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\exception.py", line 42 r response = get_response(request) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py", line 187, in ponse response = self.process_exception_by_middleware(e, request) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py", line 185, in ponse response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\user\Desktop\Myhappy\myhappy.org\home\views.py", line 220, in happyloginsf21 = sf1.query("SELECT Id, Name, Temp_Contact_LastName__c, Temp_Contact_Password__c, Temp_Contact_Active__ ary_Contact_Mobile__c,
Temp_Contact_Head__c FROM Temp_Contact__c WHERE Temp_Contact_Email__c ='{0}'".format(unam AttributeError: 'HttpResponse' object has no attribute 'query' [02/Nov/2017 13:23:28] "POST /happy/loginpage.html HTTP/1.1" 500 71539
Why is that error thrown and how can it be resolved?
salesforceconnection()
is not returning the right object type. and that's why it cannot findquery
. Can you share (with the details masked, of course) your code for salesforceconnection() ?HttpResponse object has no attribute 'query'
and yourexcept:
it seems to me that its throwing an exception and that's why you cannot continue. Check on the user login attempts to see if your attempt is there and the reason for the failure. (invalid password, invalid IP, etc)Stronger security is required
, It seems that it might be related to TLS 1.0 connections, etc.