简体   繁体   English

Zammad API:使用标签创建票证

[英]Zammad API: Create ticket with tag

For those who don't want to read the whole question:对于那些不想阅读整个问题的人:
I'm looking for the index in the API-Request (Zammad) to set a tag while creating a ticket.我正在寻找 API-Request (Zammad) 中的索引以在创建票证时设置标签。

Details:细节:
I'm using PHP to make an API-Request to my server where Zammad is installed.我正在使用 PHP 向安装了 Zammad 的服务器发出 API 请求。 The following shows the data i sent via curl:下面显示了我通过 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",
    ],
]);

After converting the data to JSON, im sending it via POST to http://<myServerIP>/api/v1/tickets将数据转换为 JSON 后,我通过 POST 将其发送到http://<myServerIP>/api/v1/tickets

What I've tried so far:到目前为止我尝试过的:
I tried guessing the index of the tag at which i failed.我试着猜测我失败的标签的索引。 The first full example is shown above.第一个完整示例如上所示。

Secondly:其次:

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

And Finally:最后:

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

Needless to say that i didn't succeed.不用说,我没有成功。 Sometimes i get an error id (im assuming its because the index doesn't exist [who would have thought that? :)]), sometimes i get nothing and Zammad just creates the ticket without the tag.有时我会收到一个错误 ID(我假设它是因为索引不存在 [谁会想到?:)]),有时我什么也得不到,而 Zammad 只是创建了没有标签的票证。 What do i mean when i say sometimes?我有时说是什么意思? I refer my tries specified above.我参考了上面指定的尝试。

What I've also tried:我也尝试过:
Searching for some answer on the web.在网上搜索一些答案。 The thing that comes close to what i want is this .接近我想要的东西是这个 But i would rather create the ticket with the tag instead of making another request just to add the tag.但我宁愿创建带有标签的票证,而不是仅仅为了添加标签而发出另一个请求。

I've looked inside the code, its written in ruby.我查看了代码内部,它是用 ruby​​ 编写的。 The index is 'tags' and needs to be sperated by , .索引是“标签”,需要用,分隔。

Basicly:基本上:

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

It might help someone in the future ...它可能会在未来帮助某人......

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

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