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
hk2012hk2012 

Unable to get contact information

Hi All,

I am trying to fetch my contact details but unable to do so
Below is my sample code
//create auth client to retrieve token
            var auth = new AuthenticationClient();

            //get back URL and token
            await auth.UsernamePasswordAsync(consumerkey, consumersecret, username, password);

            var instanceUrl = auth.InstanceUrl;
            var accessToken = auth.AccessToken;
            var apiVersion = auth.ApiVersion;

            var client = new ForceClient(instanceUrl, accessToken, apiVersion);



            //Toolkit handles all serialization
            var contacts = await client.QueryAsync<Contact>("SELECT Id, LastName From Contact");

            //loop through returned contacts
            foreach (Contact c in contacts.Records)
            {
                Console.WriteLine("Contact - " + c.LastName);
            }
I get following exception 'A first chance exception of type 'Salesforce.Common.ForceException' occurred in mscorlib.dll' while trying to get contact details.
I have added two entries in contacts which can be seen from UI.
Any guesses what can be the reason for issue?

Thanks in advance.
ShashankShashank (Salesforce Developers) 
You might want to check if REST API is enabled for your  organization. You can do it using workbench: https://developer.salesforce.com/page/Workbench