I'm working on an implementation of workfront api and my application. This is suppose to be simple. Perhaps my code will explain better.
JToken tasks = client.Search(ObjCode.TASK, new { fields = "ID, extRefID, assignedTo:name" });
taskid = c.Value<string>("ID");
workItem = c.Value<string>("extRefID");
taskAssgTo = c.Value<string>("assignedTo:name");
Now, taskid and workItem return values correctly. I'm having trouble understanding why taskAssgTo will always return null. When debuggin, I can clearly see that assignedTo:name has correct values, but for some reason I will not assign it to taskAssgTo. (taskAssgTo is a string variable).
This is how it looks when retrieving the data using REST:
{
"ID": "4c78285f00000908ea8cfd66e084939f",
"extRefId": "4561",
"assignedTo": {
"ID": "4c78285f00000908ea8cfd66e084215a",
"name": "Admin User"
}
}
Please I would appreciate an explanation and a possible solution to this. Thanks in advance!
I don't see any documentation that says that you can access child values in the manner you are trying to access them.
I would try using dot notation instead, such as
taskAssgTo = c.Value<string>("assignedTo.name");
or following the link below to see how to navigate a JObject hierarchy
Searching for a specific JToken by name in a JObject hierarchy