VersionOne API 客户端无法识别资产类型?
VersionOne API Client not recognizing asset types?
我 运行 遇到 VersionOneAPIClient 的问题,因为它无法识别我给它的任何资产类型。我知道属性定义可能没有任何意义,但我一直在尝试几乎所有的事情。我的最终目标是查询 TeamRooms 并从团队房间中的所有团队中获取团队名称。
我从 asset types and how to query 上的文档中了解到这应该有效,但我们都这么说。
我正在使用:
C# ASP.NET、VersionOneAPIClient 15.0.0.0
我试过的字符串:
- 工作室
- 任务
- 范围
项目
public bool APIgetTeams()
{
IAssetType teamroomType = services.Meta.GetAssetType("Task");
Query query = new Query(teamroomType);
IAttributeDefinition teamAttribute = teamroomType.GetAttributeDefinition("Children:Room.Team.Name");
query.Selection.Add(teamAttribute);
IAttributeDefinition scheduleAttribute = teamroomType.GetAttributeDefinition("Children:Scope.Room.Schedule.Name");
query.Selection.Add(scheduleAttribute);
query.Find = new QueryFind(scheduleName, new AttributeSelection(scheduleAttribute));
query.Paging.PageSize = 1;
query.Paging.PageSize = 0;
teamRoomAsset = (Asset)services.Retrieve(query).Assets.ToArray().GetValue(0);
return true;
}
我对服务和连接器的定义:
public static V1Connector connector = V1Connector
.WithInstanceUrl("http://versionone.cscinfo.com/VersionOneProd/")
.WithUserAgentHeader("New Dashboard?", "1.0")
.WithWindowsIntegrated()
.Build();
public IServices services = new Services(connector);
这些是我的错误/堆栈跟踪:
这个错误可能很简单,就在我面前,但我想不通。
你这里发生了几件事。我将解决您的陈述“我的最终目标是查询 TeamRooms 并从团队房间中的所有团队中获取团队名称。”
这是一个工作代码块,它读取您所有的工作室并打印团队房间的名称和团队名称。一旦你在你的机器上开始工作,尝试进行分页。逐步添加过滤以保持较低的调试周期。
static void Main(string[] args)
{
V1Connector connector = V1Connector
.WithInstanceUrl("https://www.MyV1INstance")
.WithUserAgentHeader("HappyApp", "0.1")
.WithUsernameAndPassword("login", "pwd")
.Build();
IServices services = new Services(connector);
IAssetType trType = services.Meta.GetAssetType("TeamRoom");
Query query = new Query(trType);
IAttributeDefinition teamAttribute = trType.GetAttributeDefinition("Team.Name");
IAttributeDefinition nameAttribute = trType.GetAttributeDefinition("Name");
query.Selection.Add(teamAttribute);
query.Selection.Add(nameAttribute);
QueryResult result = services.Retrieve(query);
Asset teamRooms = result.Assets[0];
foreach (Asset story in result.Assets)
{
Console.WriteLine(story.Oid.Token);
Console.WriteLine(story.GetAttribute(teamAttribute).Value);
Console.WriteLine(story.GetAttribute(nameAttribute).Value);
Console.WriteLine();
}
附录
我刚刚意识到您使用的是 WithWindowsIntegrated() 而不是 WithUsernameAndPassword()。
只需在我的示例中更改它,然后确认您以已在 VersionOne 中设置的会员身份登录到计算机。 windows int auth 信任 IIS 信任您的决定,但在允许 auth 后立即,您必须在 VersionOne 中拥有一个活跃的会员帐户才能访问 VersionOne 资产。
我 运行 遇到 VersionOneAPIClient 的问题,因为它无法识别我给它的任何资产类型。我知道属性定义可能没有任何意义,但我一直在尝试几乎所有的事情。我的最终目标是查询 TeamRooms 并从团队房间中的所有团队中获取团队名称。
我从 asset types and how to query 上的文档中了解到这应该有效,但我们都这么说。
我正在使用: C# ASP.NET、VersionOneAPIClient 15.0.0.0
我试过的字符串:
- 工作室
- 任务
- 范围
项目
public bool APIgetTeams() { IAssetType teamroomType = services.Meta.GetAssetType("Task"); Query query = new Query(teamroomType); IAttributeDefinition teamAttribute = teamroomType.GetAttributeDefinition("Children:Room.Team.Name"); query.Selection.Add(teamAttribute); IAttributeDefinition scheduleAttribute = teamroomType.GetAttributeDefinition("Children:Scope.Room.Schedule.Name"); query.Selection.Add(scheduleAttribute); query.Find = new QueryFind(scheduleName, new AttributeSelection(scheduleAttribute)); query.Paging.PageSize = 1; query.Paging.PageSize = 0; teamRoomAsset = (Asset)services.Retrieve(query).Assets.ToArray().GetValue(0); return true; }
我对服务和连接器的定义:
public static V1Connector connector = V1Connector
.WithInstanceUrl("http://versionone.cscinfo.com/VersionOneProd/")
.WithUserAgentHeader("New Dashboard?", "1.0")
.WithWindowsIntegrated()
.Build();
public IServices services = new Services(connector);
这些是我的错误/堆栈跟踪:
这个错误可能很简单,就在我面前,但我想不通。
你这里发生了几件事。我将解决您的陈述“我的最终目标是查询 TeamRooms 并从团队房间中的所有团队中获取团队名称。”
这是一个工作代码块,它读取您所有的工作室并打印团队房间的名称和团队名称。一旦你在你的机器上开始工作,尝试进行分页。逐步添加过滤以保持较低的调试周期。
static void Main(string[] args)
{
V1Connector connector = V1Connector
.WithInstanceUrl("https://www.MyV1INstance")
.WithUserAgentHeader("HappyApp", "0.1")
.WithUsernameAndPassword("login", "pwd")
.Build();
IServices services = new Services(connector);
IAssetType trType = services.Meta.GetAssetType("TeamRoom");
Query query = new Query(trType);
IAttributeDefinition teamAttribute = trType.GetAttributeDefinition("Team.Name");
IAttributeDefinition nameAttribute = trType.GetAttributeDefinition("Name");
query.Selection.Add(teamAttribute);
query.Selection.Add(nameAttribute);
QueryResult result = services.Retrieve(query);
Asset teamRooms = result.Assets[0];
foreach (Asset story in result.Assets)
{
Console.WriteLine(story.Oid.Token);
Console.WriteLine(story.GetAttribute(teamAttribute).Value);
Console.WriteLine(story.GetAttribute(nameAttribute).Value);
Console.WriteLine();
}
附录
我刚刚意识到您使用的是 WithWindowsIntegrated() 而不是 WithUsernameAndPassword()。
只需在我的示例中更改它,然后确认您以已在 VersionOne 中设置的会员身份登录到计算机。 windows int auth 信任 IIS 信任您的决定,但在允许 auth 后立即,您必须在 VersionOne 中拥有一个活跃的会员帐户才能访问 VersionOne 资产。