I have a very simple python 3.x script that is getting errors when attempting to connect. So far, it simply consists of:
from simple_salesforce import Salesforce
import pandas as pd
sf = Salesforce(instance_url='https://test.salesforce.com', session_id='<provided access token>')
metadata_sf = sf.Contact.describe()
When I do so, I get the error:
SalesforceMalformedRequest: Malformed request https://test.salesforce.com/services/data/v52.0/sobjects/Contact/describe. Response content: [{'errorCode': 'URL_NOT_RESET', 'message': 'Destination URL not reset. The URL returned from login must be set'}]
If I instead use the given URL, like this:
from simple_salesforce import Salesforce
import pandas as pd
sf = Salesforce(instance_url='https://laguna-sobject-4136-dev-ed.scratch.my.salesforce.com', session_id='<provided access token>')
metadata_sf = sf.Contact.describe()
I get the following error:
SalesforceExpiredSession: Expired session for https://laguna-sobject-4136-dev-ed.scratch.my.salesforce.com/services/data/v52.0/sobjects/Contact/describe. Response content: [{'message': 'Session expired or invalid', 'errorCode': 'INVALID_SESSION_ID'}]
I need to find out how to deal with either the 'Malformed request' error, or find out how to refresh or renew the session ID. Any assistance would be appreciated.
Also, I did go into the Domain settings in Salesforce and clicked on 'Check Availability' and it came back with a green checkmark. Finally, the access token was obtained via an automated 'sforg' app generated from Slack. The credentials I received from it were Username, Profile Name, Id, Org Id, Access Token, Instance Url, Login Url, Alias, and Password.