我正在尝试从AtTask API中检索对象,但只检索其中一些对象。 我需要的七个对象如下(每个结果在右边;如果“ok”,它们正确地给出结果):
我的代码:
JToken projects = client.Search(ObjCode.PROJECT, new { groupID = userGroupID, __LIMIT = 2000 });
foreach (var j in projects["data"].Children())
{
Console.WriteLine("Project Name: {0}", j.Value<string>("name"));
Console.WriteLine("ID: {0}", j.Value<string>("ID"));
Console.WriteLine("Refresh date: {0}", j.Value<string>("refreshDate"));
Console.WriteLine("Reference number: {0}", j.Value<int>("referenceNumber"));
Console.WriteLine("Actual completion date: {0}", j.Value<DateTime>("actualCompletionDate"));
Console.WriteLine("Portfolio ID: {0}", j.Value<string>("portfolioID"));
Console.WriteLine("Status: {0}", j.Value<string>("status"));
}
每个API密钥和字段类型都根据https://developers.workfront.com/api-docs/api-explorer/命名。
为什么refreshDate,referenceNumber,actualCompletionDate和portfolioID没有返回正确的值,而其他三个是?
答案 0 :(得分:1)
您需要在搜索中指定字段,否则它不会提取除默认信息之外的所有字段。
所以这应该有用
JToken projects = client.Search(ObjCode.PROJECT, new { groupID = userGroupID, __LIMIT = 2000 , fields = "name,ID,refreshDate,referenceNumber,actualCompletionDate,portfolioID,status"});