0

在此处输入图像描述我能够从其任务中获取用户故事的实际值、估计值和值。但是当用户故事的任务不存在时,我必须从集会的用户故事详细信息页面中获取值。

例如:(我需要从 rallyrestapi c# toolkit 获取如下所示) https://rally1.rallydev.com/#/262768386856d/detail/defect/161729744764

目前我尝试如下,但没有成功

// 查询用户故事

    [![Request storyRequest = new Rally.RestApi.Request("hierarchicalrequirement");
                storyRequest.Workspace = workspaceRef;
                // storyRequest.Project = projectRef;
                storyRequest.ProjectScopeUp = projectScopingUp;
                storyRequest.ProjectScopeDown = projectScopingDown;
                storyRequest.Fetch = new List<string>()
                {
                    "Name",
                    "ObjectID",
                    "ScheduleState",
                    "State",
                    "FormattedID",
                    "CreationDate",
                    "ReleaseDate",
                    "PlanEstimate",
                    "Iteration",
                    "StartDate",
                    "EndDate",
                    "Release",
                    "ScheduleState",
                    "Tasks",                    
                };
                string userstoryId = "";
                long userstoryObjId ;
                storyRequest.Query = new Query("Iteration.Name", Query.Operator.Equals, myIterationName);
                QueryResult queryStoryResults = rallyRestApi.Query(storyRequest);
                ConvertToJSon(queryStoryResults);
                // Fetch Actual and Estimated Time request for task
                foreach (var userstory in queryStoryResults.Results)
                {                                  
                    Rally.RestApi.Request tasksRequest = new Rally.RestApi.Request(userstory\["Tasks"\]);
                    QueryResult queryTaskResult = rallyRestApi.Query(tasksRequest);                 
                }

Request details = new Rally.RestApi.Request("details");
                details.Workspace = workspaceRef;
                // storyRequest.Project = projectRef;
                details.ProjectScopeUp = projectScopingUp;
                details.ProjectScopeDown = projectScopingDown;
                details.Fetch = new List<string>()
                {
                    "Estimate",
                    "Actuals",
                    "ToDo"
                };
                storyRequest.Query = new Query("Defect.ObjectID", Query.Operator.Equals, "298510499032");
                QueryResult detailsdata = rallyRestApi.Query(details);][1]][1]

它给出的未经授权的 401 错误。请指导我如何从集会详细信息页面获取上述字段。

4

2 回答 2

1

我在 Java 中有相同的示例,但它可能会对您有所帮助:

import com.google.gson.JsonObject;
import com.rallydev.rest.RallyRestApi;
import com.rallydev.rest.request.QueryRequest;
import com.rallydev.rest.response.QueryResponse;
import com.rallydev.rest.util.Fetch;
import com.rallydev.rest.util.QueryFilter;
import java.io.IOException;
import java.net.URI;

public class FindUserStoryByID {

  public static void main(String[] args) throws IOException {
    String host = "https://rally1.rallydev.com";
    String apiKey = "YOUR_API_KEY"; #or you may use login/password

    RallyRestApi rallyRestApi = null;

    try {
      rallyRestApi = new RallyRestApi(URI.create(host), apiKey);

      QueryRequest query = new QueryRequest("HierarchicalRequirement");
      query.setFetch(new Fetch("FormattedID", "Name", "TaskEstimateTotal", "TaskRemainingTotal",
          "TaskActualTotal"));
      query.setLimit(1000);
      query.setScopedDown(true);
      query.setQueryFilter(new QueryFilter("FormattedID", "=", "US11111"));

      QueryResponse response = rallyRestApi.query(query);

      if (response.wasSuccessful()) {
        for (int i = 0; i < response.getTotalResultCount(); i++) {
          JsonObject jsonObject = response.getResults().get(i).getAsJsonObject();
          System.out.println("FormattedID: " + jsonObject.get("FormattedID"));
          System.out.println("Name: " + jsonObject.get("Name"));
          System.out.println("TaskEstimateTotal: " + jsonObject.get("TaskEstimateTotal"));
          System.out.println("TaskRemainingTotal: " + jsonObject.get("TaskRemainingTotal"));
          System.out.println("TaskActualTotal: " + jsonObject.get("TaskActualTotal"));
        }
      }
    } finally {
      if (rallyRestApi != null) {
        rallyRestApi.close();
      }
    }
  }

}

输出将是这样的:

FormattedID: "US11111"
Name: "My cool user story"
TaskEstimateTotal: 29.0
TaskRemainingTotal: 29.0
TaskActualTotal: 0.0
于 2019-08-09T07:15:39.323 回答
0

检查https://rally1.rallydev.com/account并检查 api 密钥是否密钥访问是完全授权的,这是问题

于 2020-06-24T12:25:41.877 回答