With Rally’s rest api, how can I query to find a user’s email address?
For instance, I have this query to get a defect which contains the full name of the user who opened it and the user who owns the defect:
QueryRequest defectRequest = new QueryRequest("defect");
defectRequest.setFetch(new Fetch("Project", "LastUpdateDate", "FormattedId"));
defectRequest.setQueryFilter(new QueryFilter("Project.Name", "=", rallyProjectName).and(new QueryFilter("LastUpdateDate", ">", defectTimestamp.getTimestamp())));
QueryResponse projectDefects = rallyApi.query(defectRequest);
Now I’d like to take the Submitted By and Owner users from the defect and get their email addresses.
Make certain to include the fields “Owner” and “SubmittedBy” on your Fetch for the Defects:
Then the Owner and SubmittedBy fields on each returned Defect (if populated in Rally and not null) will have a reference to the corresponding User object in Rally. Then your inclination to do a second request for this is spot on. It’s easiest to just use that ref and do a GetRequest straight against the ref. Here’s how on the Owner field as an example (forgive the clumsy try/catch block – it’s catching empty Owner fields):