Get Ticket_Time IDs

Infos:

  • Used Zammad version: 6.0
  • Used Zammad installation type: package

Hey,

I want to export all the ticket times to an external DB over the API.

/api/v1/tickets?expand=true returns

{
      "ticket_time_accounting_ids": [
          1,
          2
      ],
}

How can I read these IDs?

The zammad 6.1 release will be time accounting related and contain also API improvements + new documentation. AFAIK the API of 6.0 only contains sums of the time accountings. You might be able to some data over the reporting endpoints but not for a single ticket without bigger efforts.

If I were you, I would wait another month, then it should be easier.

2 Likes

Hey @rolfschmidt !
Thanks for your response. I upgraded my zammad to 6.1.
Now I can access api/v1/ticket/{ID}/time_accountings/{ID}

But is there a way to access api/v1/time_accountings/{ID} so it doesn’t run

Ticket::TimeAccounting with 'id'=2 [WHERE \"ticket_time_accountings\".\"ticket_id\" = $1]

But instead something like

Ticket::TimeAccounting 'id'=2

Be aware that the 6.1 is not stable yet.

To get all time accounting for Ticket ID 1, you can use this request:

http://ubuntu-rs:3000/api/v1/tickets/1/time_accountings

ubuntu-rs@ubuntu-rs:/workspace/git_zammad/zammad$ curl -s -u"admin@example.com:test" http://ubuntu-rs:3000/api/v1/tickets/1/time_accountings | jq .
[
  {
    "id": 1,
    "ticket_id": 1,
    "ticket_article_id": 4,
    "time_unit": "55.0",
    "type_id": null,
    "created_by_id": 3,
    "created_at": "2023-09-01T09:31:47.665Z",
    "updated_at": "2023-09-01T09:31:47.665Z"
  }
]

I think the non-ticket time accounting routes are missing. I will try to add them via MR maybe we can get them into 6.1 as well. I will ask the colleagues.

@Florian-Mahlberg

Maybe as an addition:

In the ticket get with the all=true parameter you will also have this data.

ubuntu-rs@ubuntu-rs:/workspace/git_zammad/zammad$ curl -s -u"admin@example.com:test" http://ubuntu-rs:3000/api/v1/tickets/1?all=true | jq .time_accountings
[
  {
    "id": 1,
    "ticket_id": 1,
    "ticket_article_id": 4,
    "time_unit": "55.0",
    "type_id": null
  }
]

The types are not included in either of the two endpoints. If you are using the new TimeAccounting::Types then you have to grep them separately.

ubuntu-rs@ubuntu-rs:/workspace/git_zammad/zammad$ curl -s -u"admin@example.com:test" http://ubuntu-rs:3000/api/v1/time_accounting/types | jq .
[
  {
    "id": 1,
    "name": "Billing",
    "note": "",
    "active": true,
    "updated_by_id": 3,
    "created_by_id": 3,
    "created_at": "2023-09-01T09:48:18.629Z",
    "updated_at": "2023-09-01T09:48:18.629Z"
  },
  {
    "id": 2,
    "name": "Development",
    "note": "",
    "active": true,
    "updated_by_id": 3,
    "created_by_id": 3,
    "created_at": "2023-09-01T09:48:22.789Z",
    "updated_at": "2023-09-01T09:48:22.789Z"
  },
  {
    "id": 3,
    "name": "Sales",
    "note": "",
    "active": true,
    "updated_by_id": 3,
    "created_by_id": 3,
    "created_at": "2023-09-01T09:48:27.445Z",
    "updated_at": "2023-09-01T09:48:27.445Z"
  }
]

Yeah thanks. That’d be great :smiley:

Hey @rolfschmidt
Thanks for implementing ^^

1 Like

Np, personally I think this is just a sign that we need a table API. I saw requests like yours a couple of times, but I think in the end I’m not sure if we could put everything in Elasticsearch performance wise because it costs so much indexing time at the moment.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.