如何通过 API 在 Zammad 更新票证

how to update a ticket in Zammad via API

我的目标是使用 API 在 Zammad 中创建一个票证,然后更新它(for.

此类基本任务参考here

我正在使用 Postman 发送请求。

我使用不记名令牌身份验证,令牌已为 ticket.agent 用户生成(他也是管理员)。

我通过向

发送 post 请求成功创建了工单
https://myzammadinstance.com/api/v1/tickets

和这个 body:

{
    "title": "Ticket generated from API - my test",
    "group": "Users",
    "article": {
        "subject": "My Subject",
        "body": "My body",
        "type": "note",
        "internal": false
    },
    "customer": "my@email.address",
    "user": "my@email.address",
    "note": "my notes"
}

这成功创建了一个票证(具有给定的 ID,比方说 1990)。

现在我想更新这张工单,所以"replying from API"。

我向

发出 post 请求
https://myzammadinstance.com/api/v1/tickets

和这个 body:

{
  "id": 1990,
  "title": "updated title",
  "group": "Users",
  "state": "open",
  "customer_id": 12,
  "priority": "3 high",
  "article": {
    "subject": "some subject of update",
    "body": "some message of update"
  }
}

这会执行但不会将回复附加到我的 1990 票,但它会生成一张新票(ID 为 1991,标题为 "updated title")。

我不想创建新工单,只想回复现有工单。

我可能误解了什么,但我多次检查文档和请求 body。

有人可以帮忙吗?

UPDATE:如评论中所述,我似乎应该使用 https://myzammadinstance.com/api/v1/tickets/1990

但这不起作用:未创建新工单但响应有错误:

{
    "error": "No route matches [POST] /api/v1/tickets/1990"
}

解决方案

问题出在 PUTPOST 之间,通过使用 PUT 和这个端点

https://myzammadinstance.com/api/v1/tickets/1990

我成功回复了工单。

要更新票证,您需要使用此端点:

PUT /api/v1/tickets/{id}

https://docs.zammad.org/en/latest/api/ticket.html#update