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
RPKRPK 

Retrieve sample sales lead

I created a ASP.NET webAPI which should retrieve sample data like sales lead, customer information etc. from Salesforce. I have created developer account which probably has some sample data.

I referred to the code in Force.com and modified as below. It is connecting but now I want to query for sales lead and any other information.
How to modify the query in the below code:
HttpClient authClient = new HttpClient();
            HttpClient queryClient = new HttpClient();

            //set OAuth key and secret variables
            string sfdcConsumerKey = client_id;
            string sfdcConsumerSecret = client_secret;

            //set to Force.com user account that has API access enabled
            string sfdcUserName = username;
            string sfdcPassword = password;
            string sfdcToken = "<My Token>";

            //create login password value
            string loginPassword = sfdcPassword + sfdcToken;

            HttpContent content = new FormUrlEncodedContent(new Dictionary<string,string>
                  {
                     {"grant_type","password"},
                     {"client_id",sfdcConsumerKey},
                     {"client_secret",sfdcConsumerSecret},
                     {"username",sfdcUserName},
                     {"password",loginPassword}
                   }
            );

            //HttpResponseMessage message1 = await authClient.PostAsync(authorization_url, content);
            HttpResponseMessage message = await authClient.PostAsync("https://login.salesforce.com/services/oauth2/token", content);

            string responseString = await message.Content.ReadAsStringAsync();

            JObject obj = JObject.Parse(responseString);
            oauthToken = (string)obj["access_token"];
            serviceUrl = (string)obj["instance_url"];


            // Get Records
            //QUERY: Retrieve records of type "account"
            string restQuery = serviceUrl + "services/data/v25.0/query?q=SELECT+name+from+Account";

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, restQuery);

            //add token to header
            request.Headers.Add("Authorization", "Bearer " + oauthToken);

            //return JSON to the caller
            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            //call endpoint async
            HttpResponseMessage response = await queryClient.SendAsync(request);

            string result = await response.Content.ReadAsStringAsync();

As of now it is set to retrieve records of type 'Account'. How to modify the query to get other lead results?

 
Raj VakatiRaj Vakati
Change SOQL query 
string restQuery = serviceUrl + "services/data/v25.0/query?q=SELECT+name+from+Lead";

 
RPKRPK
How about if I want to pull this information: Sales order, opportunity, customer, material ?

I am only used to SQL Server. How Salesforce manages data? In Table rows and columns? Where can I check which data is available and what are the fields?