I am new to using the Workfront API and I am struggling with their documentation on how to properly set the Planned Hours (workRequired) and the Actual Hours (actualWorkRequired).
I am using their API Explorer to see the values I need to pass
Here is the body of the PUT request I am using when updating a task to set the hours (and other fields like dates / name).
{
"ID": "<TaskID>",
"name": "Example Task Via API",
"projectID": "<ProjectID>",
"plannedStartDate": "2019-07-30",
"plannedCompletionDate": "2019-08-13",
"taskConstraint": "FIXT",
"isWorkRequiredLocked": false,
"workUnit": "H",
"workRequired": 5,
"actualWorkRequired": 2,
"status": "INP"
}
The request is successful, however when I open up the task in Workfront, the hours are still 0. The name updates properly and the dates will update properly.
Any idea why the hours are not being set?
I ended up finding the answer to this and sharing along.
There are two parts to this, Planned Hours and Actual Hours
You can set the planned hours using the Task API.
/attask/api/v9.0/task
The fields that need to be set in the BODY of the request are:
{
"ID": "<taskID>"
"durationType": "A",
"workRequiredExpression": "3 Hours"
}
The actual hours use the Hour API
/attask/api/v9.0/hour
The fields that need to be set in the BODY of the request are:
{
"entryDate": "<DateField>",
"hours": "3",
"status": "SUB",
"taskID": "<taskID>"
}
This will add work hours to the task and also show up in the timesheet.