Actual Time tracking as day wise

Hello Team,

I am fetching the actual time from API but its returning me as total time in field “actual_time_minutes”: 120.
In form it maintain as day wise( list wise time entry). It will be great if you can help me to as list in API. Thank you. Sab

image

1 Like

Hi @Bastien_Siebman , @Phil_Seeman ,

Hope you are doing good. It will be great if you can help me.

Thanks in Advance.
Sab

Hi,

Sorry I never played with this part of the API, I can’t help.

Hi @Bastien_Siebman,

So there is no API endpoint for time entries in Asana against the task?

@anon6878416,

I believe what’s currently available (as of moments ago) is specified here:

You could follow that thread and also this for future updates:

Larry

1 Like

The source of truth being the documentation.

1 Like

Hi @Bastien_Siebman , @lpb ,

Thanks for you reply. Yes there is no endpoint for create time entries.
Need one more favor, I created the webhook to execute on change of Task but it seems not working for field actual_time_minutes, for other fields like name, assignee its working fine.

Would you please help me.

Thanks in Advance.
Sab

I’ll defer to others (@sasha_f?) on this. Perhaps because it’s new it’s not yet expected to work?

Thanks,

Larry

1 Like

Hi @anon6878416

Correct, at the moment there is no endpoint for creating time entries. I’m looking into webhook events on actual_time_minutes and will update you when I have more info!

1 Like

Thank you @sasha_f for your confirmation. Looking forward for webhook confirmation.

Hi @anon6878416,

It looks like we don’t emit webhook events for actual_time_minutes property changes since this property is computed.

We do however create a story/comment for these events. You should be able to see these events as stories. So you could essentially look for webhook story events with resource_subtype: 'time_tracking_entry_changed'

For example:

  1. Let’s say you establish a webhook with the following body:
{
    "data": {
        "resource": "<TASK_GID>",
        "target": "<WEBHOOK_TARGET_URL>"
    }
}
  1. Change “Actual time” field in Asana webapp
  2. Check webhook endpoint and see:
[
  {
    user: { gid: '8495784467222440', resource_type: 'user' },
    created_at: '2023-03-04T23:08:07.893Z',
    action: 'added',
    parent: {
      gid: '9475862905123326',
      resource_type: 'task',
      resource_subtype: 'default_task'
    },
    resource: {
      gid: '1903057539629037',
      resource_type: 'story',
      resource_subtype: 'time_tracking_entry_changed'
    }
  }
]

NOTE: the way we established the webhook in #1 in our example will also show other events → feel free to filter refine with filters to look for story events.

2 Likes

Hi @John_Vu ,

Thanks for your email. I am sorry to inform you that webhook is not triggering whenever i try to add some time in actual_time_minutes.

I registered the webhook as below when task getting updated. But no luck at the moment.

{
“data”: {
“filters”: [
{
“resource_type”: “task”,
“action”: “changed”
}
],
“resource”: “1111111111111111”,
“target”: “https://xxxx.com/api/xxxxx/xxxxxx
}
}

It will be great if you can let me know what i am missing or doing wrong.
Thank you for your help.
Regards,
Sab

Hi @anon6878416

The webhook filter you shared won’t yield any events for changes to “Actual time” modifications. As I explained in my previous comment, we currently do not emit changed events for actual_time_minutes on the task itself. So your request body:

{
    "data": {
      "filters": [
        {
          "resource_type": "task",
          "action": "changed"
        }
      ],
      "resource": "1111111111111111",
      "target": "https://xxxx.com/api/xxxxx/xxxxxx"
    }
  }

Is essentially saying “let me know of changed events on the task 1111111111111111” (I am assuming 1111111111111111 is a task GID).

When you modify the “Actual time” in the web app we don’t create events on the task about this change, hence why you do not see events for this webhook. Instead we create a story (i.e. a comment on the task) about this change. So what you need to do is look at the story events instead.

So try this instead:

{
    "data": {
        "filters": [
            {
                "action": "added",
                "resource_type": "story",
                "resource_subtype": "time_tracking_entry_added"
            },
            {
                "action": "added",
                "resource_type": "story",
                "resource_subtype": "time_tracking_entry_changed"
            },
            {
                "action": "added",
                "resource_type": "story",
                "resource_subtype": "time_tracking_entry_removed"
            }
        ],
        "resource": "<PROJECT_GID_OR_TASK_GID>",
        "target": "<TARGET_URL>"
    }
}

Since I mentioned that we create a story/comment event on a task for changes to “Actual time” you can use this webhook request filter to get events of when there is a change to “actual_time_minutes” (Although, we call this event time_tracking_entry_<added|changed|removed>)

NOTE: The above filter can be confusing since all the action in the filters are added

2 Likes

Thank you @John_Vu it work for. But by any chance can we get the bifurcation of Time entries like when and how much time entered, who added the time entries etc…

Hi @anon6878416, we don’t have that information available in a resource’s parameter with our current time tracking API. However, the workaround you could take is to look up the details of the story event created from modifying the time field to get that information. For example, let’s say you established a webhook like the one above so:

  1. Establish a webhook (POST /webhooks)
{
    "data": {
        "filters": [
            {
                "action": "added",
                "resource_type": "story",
                "resource_subtype": "time_tracking_entry_added"
            },
            {
                "action": "added",
                "resource_type": "story",
                "resource_subtype": "time_tracking_entry_changed"
            },
            {
                "action": "added",
                "resource_type": "story",
                "resource_subtype": "time_tracking_entry_removed"
            }
        ],
        "resource": "<PROJECT_GID_OR_TASK_GID>",
        "target": "<TARGET_URL>"
    }
}
  1. In Asana add a time in the time tracking field. Wait for story event to be sent to your webhook target URL. It should look something like this:
[
  {
    user: { gid: '<USER_GID>', resource_type: 'user' },
    created_at: '2023-03-24T17:12:33.099Z',
    action: 'added',
    parent: {
      gid: '<TASK_GID>',
      resource_type: 'task',
      resource_subtype: 'default_task'
    },
    resource: {
      gid: '<STORY_GID>',
      resource_type: 'story',
      resource_subtype: 'time_tracking_entry_added'
    }
  }
]
  1. Look up the <STORY_GID> using our Get a story (GET /stories/{story_gid}) endpoint and get the information you need. The response should look something like the following:
{
  "data": {
      "gid": "<STORY_GID>",
      "created_at": "2023-03-24T17:07:37.694Z",
      "created_by": {
          "gid": "<USER_GID>",
          "name": "<USER_NAME>",
          "resource_type": "user"
      },
      "previews": [],
      "resource_type": "story",
      "source": "web",
      "text": "<USER_NAME> added 3h 00m to actual time",
      "type": "system",
      "resource_subtype": "time_tracking_entry_added",
      "target": {
          "gid": "<TASK_GID>",
          "name": "test",
          "resource_type": "task",
          "resource_subtype": "default_task"
      }
  }
}

Here you can see that the time tracking was added at 2023-03-24T17:07:37.694Z and the user that added it in the created_by object. I realize this isn’t ideal but for now if you want that information this is one workaround I can think of.

2 Likes

Hi @John_Vu, Thank you for help. I will validate this workaround and keep you posted. Thank you for quick help.

1 Like

Hi @John_Vu ,
I hope you are doing well.
We created the webhook as per your above workaround.
Now we encountered a scenario where we are updating the Actual time entries for some of the tasks and Webhook is executing but no event request is coming hence unable to get the task details and unable to perform the business integration with another system. Also, we found automatically webhooks are deleting from the system.
Do we have any threshold for webhook ?
Any help is appreciated.
Thank you
Sab

Hi @anon6878416,

The most likely reason why your webhooks are being automatically deleted is probably due to our webhook heartbeat events.

The TLDR; with webhook heartbeat events is that Asana sends an empty payload to your webhook server ever so often and we expect your webhook server to respond to these events with a 200 response. If your webhook server/target URL does not respond to these events within X hours (~24 hours) we delete your webhook. I believe the reason for this behavior is for us to clean up un-used webhooks. This explains your experience with “Webhook is executing but no event request is coming”.

As for the new scenario you encountered with updating the actual time how often are you making the update? For example, did you add time and then a few seconds after modified that time?

Hi @John_Vu ,

Thanks for the clarification and quick response, I changed to code the return as 200 OK response for an empty event.
We are only adding the time(not editing) then the event comes as zero for many of the webhooks.

Thanks,
Sab

Hi @anon6878416,

Do yo mind sharing with us the filters you used/request body you sent when establishing that webhook? If you don’t remember you could also fetch that information by calling our Get multiple webhooks endpoint then taking the GID of the specific webhook you registered and making a call to Get a webhook

Make sure to hide any sensitive information when replying with that information.

The reason why I ask is because I was able to get events with the following request body:

{
    "data": {
        "filters": [
            {
                "action": "added",
                "resource_type": "story",
                "resource_subtype": "time_tracking_entry_added"
            },
            {
                "action": "added",
                "resource_type": "story",
                "resource_subtype": "time_tracking_entry_changed"
            },
            {
                "action": "added",
                "resource_type": "story",
                "resource_subtype": "time_tracking_entry_removed"
            }
        ],
        "resource": "<PROJECT_GID_OR_TASK_GID>",
        "target": "<TARGET_URL>"
    }
}

Additionally, could you share with us how you added the time? EX: