如何从 Rally 中获取相关对象 API

How to get related objects from Rally API

使用 node.js 中的 REST api,我正在执行 PortfolioItem/features 查询并收到以下示例结果...

{ _rallyAPIMajor: '2',
       _rallyAPIMinor: '0',
       _ref: 'https://rally1.rallydev.com/slm/webservice/v2.0/portfolioitem/feature/number',
       _refObjectUUID: '...',
       _objectVersion: '52',
       _refObjectName: 'Product',
       CreationDate: '2013-05-28T15:27:23.920Z',
       _CreatedAt: 'May 28, 2013',
       ObjectID: 112345,
       ObjectUUID: '...',
       VersionId: '52',
       Subscription: [Object],
       Workspace: [Object],
       Changesets: [Object],
       Connections: [Object],
       CreatedBy: [Object],
       Description: '',
       Discussion: [Object],
       DisplayColor: '#848689',
       Expedite: false,
       FormattedID: 'F6',
       LastUpdateDate: '2016-06-23T17:53:20.456Z',
       LatestDiscussionAgeInMinutes: null,
       Milestones: [Object],
       Name: 'Product',
       Notes: '',
       Owner: [Object],
       Project: [Object],
       Ready: false,
       RevisionHistory: [Object], ...

我有兴趣从 Project: [Object]Owner: [Object] 获取项目名称和所有者名称。

使用 Fetch: 'true' 检索对象的所有字段,不包括项目或所有者的 _ref: (a url)_refObjectUUID: (internal object ID)

我对 Project:_refObjectNameOwner:_refObject 这个名字感兴趣。

我不知道如何从功能中获取这些其他对象。

当然可以,只需将您想要水合的字段添加到您的提取中即可。一般来说,fetch=true 会很慢,所以只包含你需要的字段。获取级联,因此如果您获取名称,您将在包含该字段的任何对象上获取它。

所以在你的情况下,是这样的:

fetch: ['Project', 'Name', 'Owner']

应始终为响应中的任何对象返回 _ref 和 _refObjectName。

通过适当的水合作用,这有效使用:

var projectName = result.Results[x].Project.Name;
var ownerName = result.Results[x].Owner._refObjectName;