I'm trying to create a request for Google Sheets, but I'm having problems with the sortSpecs method.
var test = new Request()
{
SortRange = new SortRangeRequest()
{
Range = new GridRange()
{
SheetId = 0,
StartRowIndex = 1
},
SortSpecs = new SortSpec()
{
SortOrder = "ASCENDING",
DimensionIndex = 0
}
}
};
When using this, everything works correctly except for the SortSpec. Visual Studio gives the error:
Cannot implicitly convert type 'Google.Apis.Sheets.v4.Data.SortSpec' to System.Collections.Generic.IList' An explicit conversion exists
UPDATE:
There are no more build errors, but now I have another error when executing the code.
List<Data.Request> requests = new List<Data.Request>(); // TODO: Update placeholder value.
Data.SortSpec so = new Data.SortSpec();
so.SortOrder = "ASCENDING";
Data.SortSpec di = new Data.SortSpec();
di.DimensionIndex = 0;
List<Data.SortSpec> ss = new List<Data.SortSpec>();
ss.Add(so);
ss.Add(di);
var test = new Request()
{
SortRange = new SortRangeRequest()
{
Range = new GridRange()
{
SheetId = 0,
StartRowIndex = 1
},
SortSpecs = ss
}
};
requests.Add(test);
The exception given is
Message[Invalid requests[0].sortRange: No sort order specified.] Location[ - ] Reason[badRequest] Domain[global]