【问题标题】:Zammad API: Create ticket with tagZammad API:使用标签创建票证
【发布时间】:2021-02-23 11:15:44
【问题描述】:

对于那些不想阅读整个问题的人:
我正在寻找 API-Request (Zammad) 中的索引,以便在创建票证时设置标签。

详情:
我正在使用 PHP 向安装了 Zammad 的服务器发出 API 请求。下面是我通过 curl 发送的数据:

json_encode([
    "title" => $title,
    "group_id" => 2,
    "priority_id" => 2,
    "category" => 'Some Category',
    "state_id" => 1,
    "type" => "Some Type", 
    "customer" => $userID, 
    "article" => [
        "body" => $htmlBody,
        "type" => "note",
        "content_type" => "text/html",
    ],
    "tag_list" => [ // <-- The question is about this segment
        "The tag i want to add",
    ],
]);

将数据转换为 JSON 后,我通过 POST 将其发送到 http:///api/v1/tickets

到目前为止我所做的尝试:
我试着猜测我失败的标签的索引。 第一个完整示例如上所示。

其次:

...
"tag_id" => 9, // I've check its the actual ID of the tag i want to add

最后:

...
"tag" => "The tag i want to add",

不用说我没有成功。有时我得到一个错误 ID(我假设它是因为索引不存在 [谁会想到?:)]),有时我什么也没得到,Zammad 只是创建没有标签的票。我有时说什么是什么意思?我参考了上面指定的尝试。

我也尝试过:
在网上搜索一些答案。接近我想要的东西是this。但我宁愿创建带有标签的票证,而不是仅仅为了添加标签而发出另一个请求。

【问题讨论】:

    标签: php api zammad


    【解决方案1】:

    我查看了代码内部,它是用 ruby​​ 编写的。索引是'tags',需要,分隔。

    基本上:

    json_encode([
        "title" => $title,
        "group_id" => 2,
        "priority_id" => 2,
        "category" => 'Some Category',
        "state_id" => 1,
        "type" => "Some Type", 
        "customer" => $userID, 
        "article" => [
            "body" => $htmlBody,
            "type" => "note",
            "content_type" => "text/html",
        ],
        "tags" => "tag1,tag2,tag3", // or simply "tags" => "tag1"
    ]);
    

    它可能会在未来帮助某人......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多