Here is my code and yes it should be in the same Namespace:
User enters a value to look up which is the strVal
try
{
Request request = new Request("hierarchicalrequirement");
request.Fetch = new List<string>()
{
"Name",
"FormattedID",
"Iteration",
"PlanEstimate",
"Release",
"ScheduleState",
"TaskEstimateTotal",
"TaskRemainingTotal",
"c_SR",
"Children",
"Tasks",
"Owner",
"c_Complexity",
"c_Application",
"c_AppPts",
"Project",
"c_MilePts",
"c_NASAAcceptedDate",
"ObjectID",
"Actuals",
"Estimate",
"ToDo",
"TimeSpent"
};
request.Query = new Query("c_SR", Query.Operator.Equals, strVal.Trim())
.Or(new Query("c_SR", Query.Operator.Contains,strVal.Trim()));
request.Start = firstrecord;
request.Workspace = null;
request.PageSize = 200;
request.Limit = 100000;
request.Order = "FormattedID";
RallyRestApi restApi = Common.getRestApi;
Rally.RestApi.Response.QueryResult qr = restApi.Query(request);
totalrecords = qr.TotalResultCount;
if (totalrecords > 0)
{
dt = CreateDataTable();
foreach (var result in qr.Results)
{
//Get UserSTory INfo
strFormatttedID = result["FormattedID"];
DataRow dtrow;
dtrow = dt.NewRow();
dtrow["UserStoryID"] = strFormatttedID;
dtrow["SR"] = result["c_SR"];
dtrow["Story Name"] = result["Name"];
dtrow["Application"] = result["c_Application"];
//dtrow["App Points"] = result["c_AppPts"];
dtrow["Complexity"] = result["c_Complexity"];
dtrow["ObjectType"] = "U";
dt.Rows.Add(dtrow);
//Get MilestoneInfo and Task
var children = result["Children"];
var chCount = children.Count;
if (chCount> 0) //if no children then it's a milestone
{
Request childRequest = new Request(result["Children"]);
QueryResult childQueryResult = restApi.Query(childRequest);
foreach (var resultChild in childQueryResult.Results)
//foreach (var resultChild in children)
{
DataRow dtrow1;
dtrow1 = dt.NewRow();
dtrow1["MileStone ID"] = resultChild["FormattedID"];
dtrow1["MileStone Name"] = resultChild["Name"];
if (resultChild["Project"] != null)
{
var proj = result["Project"];
String projref = proj["_ref"];
var projFetch= restApi.GetByReference(projref, "Name");
dtrow1["LOB"] = projFetch["Name"];
}
else {dtrow1["LOB"] = "";}
dtrow1["NASA Accepted Date"] = (Common.CheckDate(result["c_NASAAcceptedDate"]) == DateTime.MinValue ? " " : String.Format("{0:MM/dd/yyyy hh:mm:ss}", Common.CheckDate(result["c_NASAAcceptedDate"])));
if (resultChild["Iteration"] != null)
{
var iteration = resultChild["Iteration"];
String iterationref = iteration["_ref"];
var iterationFetch = restApi.GetByReference(iterationref, "Name");
dtrow1["Iteration"] = iterationFetch["_refObjectName"];
}
else
{
dtrow1["Iteration"] = "";
}
if (resultChild["Release"] != null)
{
var release = resultChild["Release"];
String releaseref = release["_ref"];
var releaseFetch = restApi.GetByReference(releaseref, "Name");
dtrow1["Release"] = releaseFetch["_refObjectName"];
}
else
{
dtrow1["Release"] = "";
}
dtrow1["State"] = resultChild["ScheduleState"];
dtrow1["PlanEst"] = resultChild["PlanEstimate"];
dtrow1["TaskEst"] = resultChild["TaskEstimateTotal"];
dtrow1["ToDo"] = resultChild["TaskRemainingTotal"];
dtrow1["ObjectType"] = "M";
var uTasks = resultChild["Tasks"];
dtrow1["TaskCount"] = uTasks.Count;
dt.Rows.Add(dtrow1);
if (uTasks.Count > 0)
{
Request taskRequest = new Request(resultChild["Tasks"]);
QueryResult TaskQueryResult = restApi.Query(taskRequest);
foreach (var items in TaskQueryResult.Results)
{
DataRow dtrow2;
dtrow2 = dt.NewRow();
dtrow2["TaskID"]=items["FormattedID"];
dtrow2["Task Name"] = items["Name"];
dtrow2["Task-Est"] = items["Estimate"];
dtrow2["Task-ToDo"] = items["ToDo"];
decimal ts = 0;
ts = ts + items["TimeSpent"];
dtrow2["Task-Spent"] = ts;
if (items["Owner"] != null)
{
var owner = items["Owner"];
String ownerref = owner["_ref"];
var ownerFetch = restApi.GetByReference(ownerref, "Name");
string strTemp = ownerFetch["_refObjectName"];
dtrow2["Owner"] = strTemp.Replace(",", " ");
}
else { dtrow2["Owner"] = ""; }
dtrow2["ObjectType"] = "T";
dt.Rows.Add(dtrow2);
}
}
}
}
}
Then I get all the information except for Timespent which is 0.0
I do see the Timespent within that rally application like your picture(sorry can't figure out how to paste one into here)
For webservice not sure how to get <WORKSPACE_OID> but I see the time spent when I use the webservice on the on one of the tasks
https://xxxxx/slm/webservice/v2.0/task/89601445
Thanks,
JT