I have a method that pulls a csv from a website using restsharp.
class ScheduledBilling
{
public string Report()
{
var client = new RestClient("http://example.com");
client.CookieContainer = new System.Net.CookieContainer();
client.Authenticator = new SimpleAuthenticator("username", "xxx", "password", "xxx");
var request = new RestRequest("/login", Method.POST);
IRestResponse response = client.Execute(request);
var ScheduledBilling = client.DownloadData(new RestRequest("/file));
var csv = System.Text.Encoding.Default.GetString(ScheduledBilling);
return(csv);
}
}
In main, I've been using a mix of tutorials and the quickstart so that I can enter information into a google sheet.
//ScheduledCRMBilling.Report();
ScheduledCRMBilling obj = new ScheduledCRMBilling();
string csv = obj.Report();
String spreadsheetId2 = "xxx";
String range1 = "Scheduled Billing";
ValueRange valueRange1 = new ValueRange();
valueRange1.MajorDimension = "ROWS";//"ROWS";//COLUMNS
var oblist1 = new List<object>() { csv };
SpreadsheetsResource.ValuesResource.UpdateRequest update1 = service.Spreadsheets.Values.Update(valueRange1, spreadsheetId2, range1);
update1.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.RAW;
UpdateValuesResponse result1 = update1.Execute();
Console.WriteLine("done!");
I've set the range to be the entire sheet (Scheduled Billing). What happens is that the first cell is filled with all the information in the csv, and not as if you would import a csv into google sheets. How should I proceed? I feel as if I should pass the csv variable as a list of strings, which would place a string in each cell. But then I don't know how it would know when it's time for a new line.