繁体   English   中英

Zammad API:使用标签创建票证

[英]Zammad API: Create ticket with tag

对于那些不想阅读整个问题的人:
我正在寻找 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://<myServerIP>/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 只是创建了没有标签的票证。 我有时说是什么意思? 我参考了上面指定的尝试。

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

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

基本上:

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"
]);

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM