如何在通过 API 创建主题时查找标签 ID 以添加标签

I wanna create topic via API

How find tags id to add tags when create topic via API

Thank!

AFAIK you don’t need tag ids. You can just pass the tag names.

Does anyone know if this should work in 2.0.0.beta9? Tags are not mentioned in the API docs for POST /posts.
I tried to create topics with tags="testtag" but got a HTTP 500 error.

From the logs:

NoMethodError (undefined method `-' for "testtag":String)                                                                                                                                                                                       
/var/www/discourse/lib/discourse_tagging.rb:220:in `tags_for_saving' 

You should try like tags[]="testtag". It’s an array type.

无法正常工作。有没有办法添加标签?

这不起作用,我的调用看起来像:

$body = '{
            "async": false,
            "title": "'.$word.'",
            "raw": "'.$definition.'",
            "category":'.$categoryId.',
            "topic_id": '.$topicsId.',
            "tags[]": "test-tag"
        }';

它会创建主题,但不会创建或将标签添加到新主题中。@vinothkannans