Webhook field "actual_time_minutes" does not provide GID or time entry value

After creating a webhook for a task change and logging the response when this webhook is triggered I’m experiencing some problems in accessing the information about the new time entry.

My response on a task change looks as follows:

Array
(
    [events] => Array
        (
            [0] => Array
                (
                    [action] => changed
                    [parent] => 
                    [change] => Array
                        (
                            [field] => actual_time_minutes
                            [action] => changed
                        )
                    [created_at] => 2024-05-08T10:52:03.736Z
                    [user] => Array
                        (
                            [gid] => 1207021763972439
                            [resource_type] => user
                        )
                    [resource] => Array
                        (
                            [gid] => 1207264916812802
                            [resource_type] => task
                            [resource_subtype] => default_task
                        )
                )
        )
)

So far so good. But where is the GID of the “actual_time_minutes” entry that has been added?
Or at least the amount of time that has been added?

Without any of those information I am not able to work with the time entry. However I have to deal with the time so I need specific details.

Without the GID I can’t get detailed information using the endpoint Get a time tracking entry

I’ve already looked into different topics discussing the time tracking entries accessability via API and it seems like either I didn’t found the correct way to get the details or, as I read, it is really not available and that’s why others also struggling with that.

Hello, @Alexander_Weißgerber

To access the detailed information about the time entry, you might need to make an additional API call to the task’s endpoint using the gid of the task provided in the webhook response. This follow-up call would retrieve the task’s full details, including the actual_time_minutes field, which should reflect the new time entry.

Here’s a general approach you could take:

Capture the Task GID: From the webhook response, extract the gid of the task that has been changed.
API Call to Task Endpoint: Use the task gid to make an API call to the task’s endpoint to fetch the full details of the task.
Extract Time Entry Details: From the task details response, locate the actual_time_minutes field to find the updated time entry details.

Here’s a pseudocode example of how you might implement this:

Pseudocode for fetching detailed time entry information

task_gid = webhook_response[‘events’][0][‘resource’][‘gid’]

Make an API call to the task endpoint using the task_gid

task_details = api_call(‘GET’, f’/tasks/{task_gid}')

Extract the actual_time_minutes from the task details

time_entry_details = task_details[‘actual_time_minutes’]

Now you have the detailed time entry information

If the API does not provide the historical time entry details directly, you may need to compare the current state of the actual_time_minutes with a previously stored state to determine the amount of time that has been added.

I hope my suggestion is helpful for you.

Best Regard,
Angela Huey

Hi @Alexander_Weißgerber,

I’m pretty sure the above response was generated by an AI chatbot. It’s correct in the opening paragraph:

After that, though, I think it’s not very helpful and probably will confuse your efforts.

So to try and help out:

As it says, you will need to take the task gids you get in your webhook events and make an additional call for each task to get the actual contents of the task including actual_time_minutes. As it says in the API docs:

Note that events are “compact” and contain only some basic details of the change, not the whole resource. We expect integrations to make additional requests to the API to retrieve the latest state from Asana.

When you do make the follow-up call to get a task’s data based on the task gid you got in the webhook event, by default (for efficiency’s sake) Asana does not include all properties on the task. For many properties, you need to ask for it specifically. In this case, I think if you specify
?opt_fields=actual_time_minutes
in your query, you’ll get the value of that property.

3 Likes

Hey @Phil_Seeman,

thank you for your reply.
Unfortunately the request with the opt_fields parameter does not provide the necessary information I need. It returns only the total amount of tracked time and not a list of time entries.
However, even a list wouldn’t help much, because I need the latest time entry in the moment the webhook is triggered because of a new time entry (or modified/removed).

I found this topic that also focuses on single time tracking entries and that worked for me. Unfortunately it also does not provide a real value for the time entry but a text that doesn’t help much when I need the amount of added time.

Isn’t there a way to just get the value/amount of added time when a time entry has been added or modified?

I’m still struggling with the Webhooks and Time Tracking Entries. :face_with_raised_eyebrow:
When I look into the Webhooks Guide there is the resource_type “Time Tracking Entry - added, changed, deleted” listed so I tried to establish a webhook for new time tracking entries, which I want to be fired when a task is changed or added or whatever but how do I do this?

The filters are set to:

array_push($aFilters, [
	"action" => "added",
	"resource_type" => "time_tracking_entry",
]);
array_push($aFilters, [
	"action" => "changed",
	"resource_type" => "time_tracking_entry",
]);
array_push($aFilters, [
	"action" => "deleted",
	"resource_type" => "time_tracking_entry",
]);

And the resource for establishing the webhook is set to the GID of the task, which directly fails by returning “Invalid Request”.

How do I set up a webhook for Time Tracking Entries?

@Alexander_Weißgerber These are good questions. It’s not clear from the documentation. I’ve asked on the main time-tracking API thread:

2 Likes

Thank you @Phil_Seeman to repost my question in the main thread.
Hopefully one of the two people who seem to have knowledge on how to establish a “Time Tracking Entry Webhook” will reply soon. Being able to establish that type of webhook would help us a lot to work better with our time management.