質問

When I query Rally REST API (.net) I am able to get all the user values except the following fields:

  1. Role
  2. CostCenter
  3. LastLoginDate
  4. OfficeLocation
  5. c_RoleType
  6. CreationDate

When I fire up a url "https://rally1.rallydev.com/slm/webservice/v2.0/user/xxxxxxxxxx" in a browser I am able to access all the above fields.

However, when I use REST API the result set doesn't include any of the above fields.

Not sure if I need to do anything differently.

request = new Request("user");
request.Fetch = fetchList;
request.Workspace = RallyInterface.workspaceRef;
QueryResult queryResult = restApi.Query(request);

PS. In above example Fetch string is empty and the aim is to fetch all the possible user fields. When I debug I am only able to get the following 18 fields

    [0] "_rallyAPIMajor"    string
    [1] "_rallyAPIMinor"    string
    [2] "_ref"  string
    [3] "_refObjectUUID"    string
    [4] "_objectVersion"    string
    [5] "_refObjectName"    string
    [6] "ObjectID"  string
    [7] "Department"    string
    [8] "Disabled"  string
    [9] "DisplayName"   string
    [10]    "EmailAddress"  string
    [11]    "FirstName" string
    [12]    "LastName"  string
    [13]    "MiddleName"    string
    [14]    "Phone" string
    [15]    "Role"  string
    [16]    "UserName"  string
    [17]    "_type" string

Also, when I use GetByReference(), I am able to get the value for "Role" but not for any of the following fields:

  1. CostCenter
  2. LastLoginDate
  3. OfficeLocation
  4. c_RoleType
  5. CreationDate

GetByReference() response returns with field not found message.

役に立ちましたか?

解決

The fetchList should include those fields, or should be entirely omitted. The code example below returns those fields in both cases. It means if I comment out userRequest.Fetch in the code below, those fields will still be returned. If a fetch is present, but does not include those fields, they will not be returned.

            userRequest.Fetch = new List<string>()
                {
                   "Role",
                   "CostCenter",
                   "LastLoginDate",
                   "OfficeLocation",
                   "CreationDate"
                };

            userRequest.Query = new Query("UserName", Query.Operator.Equals, "user@co.com");

            QueryResult userResults = restApi.Query(userRequest);

            foreach (var u in userResults.Results)
            {
                Console.WriteLine("Role: " + u["Role"] + " CostCenter: " + u["CostCenter"] + " LastLoginDate: " + u["LastLoginDate"] + " OfficeLocation: " + u["OfficeLocation"] + " CreationDate: " + u["CreationDate"]);
            }

Here is another variation of this code when GetByReference is used:

userRequest.Query = new Query("UserName", Query.Operator.Equals, "user@co.com");

        QueryResult userResults = restApi.Query(userRequest);
        String userRef = userResults.Results.First()._ref;
        DynamicJsonObject user = restApi.GetByReference(userRef, "Name", "Role", "CostCenter", "LastLoginDate", "OfficeLocation", "CreationDate");
        String role = user["Role"];
        String costCenter = user["CostCenter"];
        String lastLoginDate = user["LastLoginDate"];
        String officeLocation = user["OfficeLocation"];
        String creationDate = user["CreationDate"];

        Console.WriteLine("Role: " + role + " CostCenter: " + costCenter + " LastLoginDate: " + lastLoginDate + " OfficeLocation: " + officeLocation + " CreationDate: " + creationDate);

The full code is available in this github repo.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top