I wrote a utility that cycles through a bunch of orgs and pulls out information. I'm using the Partner SOAP API and C# to do this. Now, I'm trying to get some additional information that is only available with the Tooling API. I've figured out how to make the Tooling API connection and when I run this query, it works:
string SOQL = "SELECT SharingModel FROM CustomObject WHERE DeveloperName = 'Booking'";
ToolingService.QueryResult qr = new ToolingService.QueryResult();
qr = ts.query(SOQL);
However, if I change the SOQL string to a Select Count, it fails on the ts.query(SOQL) line. An example aggregate query that fails is:
string SOQL = "Select count(Id) From ValidationRule where EntityDefinition.DeveloperName = 'Booking'";
The error is: Exception occured There is an error in XML document (1, 433).
The Aggregate query works fine in the developer console.
I'm sure this is some sort of a casting issue but I just can't find it. I'm guessing that the aggregate result can't come back into the QueryResult sObject. I've been reading through the Tooling API Reference.cs file trying to figure it out but I haven't had any luck. Any ideas what I need to change so an aggregate query will work?
Select count() From ValidationRule where EntityDefinition.DeveloperName = 'Booking'
qr.result.size
? , or just try printing qr to see what it has?