public static async Task<string> ExecuteReport() { var sf_client = new Salesforce.Common.AuthenticationClient(); sf_client.ApiVersion = "v34.0"; await sf_client.UsernamePasswordAsync(consumerKey, consumerSecret, username, password + usertoken, url); string reportUrl = "/services/data/" + sf_client.ApiVersion + "/analytics/reports/" + reportId; var client = new RestSharp.RestClient(sf_client.InstanceUrl); var request = new RestSharp.RestRequest(reportUrl, RestSharp.Method.GET); request.AddHeader("Authorization", "Bearer " + sf_client.AccessToken); var restResponse = client.Execute(request); var reportData = restResponse.Content; return reportData; }
public static async Task <string> ExecuteReport() { var sf_client = new Salesforce.Common.AuthenticationClient(); sf_client.ApiVersion = "v34.0"; await sf_client.UsernamePasswordAsync(consumerKey, consumerSecret, username, password + usertoken, url); string reportUrl = "/services/data/" + sf_client.ApiVersion + "/analytics/reports/" + reportId; var client = new RestSharp.RestClient(sf_client.InstanceUrl); var request = new RestSharp.RestRequest(reportUrl, RestSharp.Method.GET); request.AddHeader("Authorization", "Bearer " + sf_client.AccessToken); var restResponse = client.Execute(request); var reportData = restResponse.Content; return(reportData); }
static async Task Main(string[] args) { var appArguments = SetupCommandLineParser(args); Console.WriteLine("Salesforce Object to Poco Generator for Rest API calls."); ForceClient forceClient = null; using (var auth = new Salesforce.Common.AuthenticationClient()) { await auth.UsernamePasswordAsync(appArguments.ConsumerKey, appArguments.ConsumerSecret, appArguments.UserName, appArguments.PasswordAndToken, appArguments.TokenUrl); forceClient = new ForceClient(auth.InstanceUrl, auth.AccessToken, "v50.0"); } // get object description from Salesforce API var describeObjectInfo = await forceClient.DescribeAsync <SalesforceObjectDescribe>(appArguments.ObjectApiName); // generate c# class into string var classStr = ($@" namespace {appArguments.Namespace} {{ public class {appArguments.ObjectApiName} {{ {string.Join("\r\n", describeObjectInfo.Fields.Select(x=> $" public {GetCSharpType(x.SoapType, x.Nillable)} {x.Name} {{get; set;}} " )) } }} }} "); Console.WriteLine(classStr); // write to file if (!string.IsNullOrEmpty(appArguments.FileOutput)) { File.WriteAllText(appArguments.FileOutput, ""); } }