I want to write a rest client that will add hours to a particular workfront task. i.e. add more of these:
The docs are not very clear on this though. They're not very clear on anything TBF, it's just a list of objects with no examples of how to relate them. It's like trying to learn Spanish with just a dictionary!
I've attempted to do a POST of a new Hour thus:
POST https://company.attask-ondemand.com/attask/api/v7.0/hour?apiKey=<api key>
Body
{
"objCode": "HOUR",
"entryDate": "2018-01-18",
"hours": 1,
"status": "SUB",
"taskID" : "<task id>"
}
But all I get back from workfront is:
{
"data": {
"objCode": "HOUR",
"ID": null
}
}
Interestingly if I search for Hours for tasks:
GET https://company.attask-ondemand.com/attask/api/v7.0/hour/search?taskID=<task ID>&apiKey=<api key>
I get hours back but they don't contain any TaskIds:
{
"data": [
{
"ID": "<id>",
"objCode": "HOUR",
"entryDate": "2018-01-16",
"hours": 3,
"status": "SUB"
},
{
"ID": "<id>",
"objCode": "HOUR",
"entryDate": "2018-01-15",
"hours": 1,
"status": "SUB"
},
{
"ID": "<id>",
"objCode": "HOUR",
"entryDate": "2018-01-18",
"hours": 0.75,
"status": "SUB"
}
]
}
Even though the docs state that this object contains a taskId
field?
Does anyone have any experience of this? How do I add a new Hour to a Task object?
You're almost there. You just need to send a little more data. I'm not sure what the minimum required fields are, but I was able to log 1 hour under a given user for a given task on a given date and have it appear under the task just fine.
POST https://x.my.workfront.com/attask/api/v7.0/hour?taskID=<id of task>&ownerID=<user to log hours under>&hours=1.0&entryDate=2017-12-27&apiKey=<key>"
Note that instead of TaskID you could pass other valid ID types such as an issue.