I can replicate the same error when using the latest dll from Rally REST .NET Toolkit's repo and v2.0 of WS API (which we encourage users to do, since 1.43 of WS API will not be supported after June of this year per this schedule).
To make your code work with v2.0 of WS API I modified your code slightly to make a separate call to get the objects of TeamMembers collection:
Request teamRequest = new Request(myProject["TeamMembers"]);
QueryResult teamResult = restApi.Query(teamRequest);
foreach (var teammate in teamResult.Results)
{
userMap.Add(teammate["_refObjectName"], teammate["_ref"]);
userList.Add(teammate["_refObjectName"]);
}
In v2.0 of Rally Web Services API we removed the ability to return child collections in the same response for performance reasons. In v2.0 fetching a collection will return an object with the count and the url from which to get the collection. In the older versions of WS API certain fetch lists create a lot recursive calls, and all the collections included in the fetch make the call quite expensive. In WS API v2.0 this will not happen, since a separate call will have to be made in order to get objects of the collections.
If you encountered this problem when running your code against WS API 1.43 or older, please try again since yesterday we had a temporarily issue that affected 1.43 when fetch included Releases. This issue was resolved the same day.
Here is a full code that works with v2.0 of WS API:
static void Main(string[] args)
{
RallyRestApi restApi;
restApi = new RallyRestApi("user@co.com", "secret", "https://rally1.rallydev.com", "v2.0");
String workspaceRef = "/workspace/12352608129";
try
{
Request projectRequest = new Request("project");
projectRequest.Fetch = new List<string>()
{
"Name",
"Owner",
"State",
"Description",
"Workspace",
"TeamMembers",
"Releases"};
projectRequest.Workspace = workspaceRef;
String projectName = "Company X";
projectRequest.Query = new Query("Name", Query.Operator.Equals, projectName);
QueryResult queryProjectResults = restApi.Query(projectRequest);
DynamicJsonObject myProject = queryProjectResults.Results.First();
String myProjectReference = myProject["_ref"];
var projectState = myProject["State"];
List<string> userList = new List<string>();
userList.Add("");
Dictionary<string, string> userMap = new Dictionary<string, string>();
Request teamRequest = new Request(myProject["TeamMembers"]);
QueryResult teamResult = restApi.Query(teamRequest);
foreach (var teammate in teamResult.Results)
{
userMap.Add(teammate["_refObjectName"], teammate["_ref"]);
userList.Add(teammate["_refObjectName"]);
}
userList.Sort();
Console.WriteLine("Test user: " + userMap["nick01"]);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}