Search code examples
c#objectattask

AtTask is not retrieving all objects


I am trying to retrieve objects from the AtTask API, but only some of them are being retrieved. The seven objects I need are as follows (with each result on the right; if "ok", they are giving results correctly):

  • projectName - ok
  • ID - ok
  • refreshDate - blank
  • referenceNumber - all return 0
  • actualCompletionDate - all return 1/1/0001 12:00:00 am
  • portfolioID - blank
  • status - ok

My code:

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"));
}

Each API key and field type are named according to https://developers.workfront.com/api-docs/api-explorer/.

Why aren't refreshDate, referenceNumber, actualCompletionDate, and portfolioID returning correct values, while the other three are?


Solution

  • you need to specify fields in your search otherwise it will not pull all but the default information.

    so this should work

    JToken projects = client.Search(ObjCode.PROJECT, new { groupID = userGroupID, __LIMIT = 2000 , fields = "name,ID,refreshDate,referenceNumber,actualCompletionDate,portfolioID,status"});