I have a small class that helps me pull salesforceobject dataframes and columns. I am having an issue with the SFType from the simple_salesforce package. I am trying to retrieve the column headers from the dataframe of a certain salesforce object. Here is a snippet of my class:
from simple_salesforce import Salesforce
from simple_salesforce import SFType
import pandas as pd
import numpy as np
class SfData:
def __init__(self,user,pw,token,obj):
self.user = user
self.pw = pw
self.token = token
self.sf = Salesforce(username = self.user,password = self.pw, security_token=self.token)
self.obj = obj
def retrieve_columns(self):
df = SFType(self.obj, self.sf.session_id, self.sf.sf_instance)
col_names = [x['name'] for x in self.sf.df.describe()['fields']]
return col_names
After calling the class I get the following error when I call the method:
test.SfData(myuser,mypw,mytoken,"Account")
test.retrieve_columns()
Resource df Not Found. Response content: [{'errorCode': 'NOT_FOUND', 'message': 'The requested resource does not exist'}]
I didn't need use my credentials to call the method "describe", instead:
df = SFType(self.obj, self.sf.session_id, self.sf.sf_instance)
data = df.describe()
columns = [x['name'] for x in data['fields']]
return columns