API経由でトピックを割り当てる方法

Discourse Assign は、次の API エンドポイントを公開します。

割り当て (PUT /assign/assign.json)

必須パラメーター:

  • target_id - トピックまたは投稿の ID
  • target_type - \"Topic\" または \"Post\" のいずれか

次のいずれか 1 つ:

  • username - 割り当てるユーザー名
  • group_name - 割り当てるグループ名

オプションパラメーター:

  • note - 割り当てメモ
  • status - 割り当てステータス
  • should_notify - 通知を送信する (デフォルト: true)

割り当て解除 (PUT /assign/unassign.json)

必須パラメーター:

  • target_id - トピックまたは投稿の ID
  • target_type - \"Topic\" または \"Post\" のいずれか

例 (curl)

# トピック 123 をユーザー "john" に割り当てる
curl -X PUT "https://your-discourse.com/assign/assign.json" \
  -H "Api-Key: YOUR_API_KEY" \
  -H "Api-Username: YOUR_USERNAME" \
  -H "Content-Type: application/json" \
  -d '{"target_id": 123, "target_type": "Topic", "username": "john"}'

# 代わりにグループに割り当てる
curl -X PUT "https://your-discourse.com/assign/assign.json" \
  -H "Api-Key: YOUR_API_KEY" \
  -H "Api-Username: YOUR_USERNAME" \
  -H "Content-Type: application/json" \
  -d '{"target_id": 123, "target_type": "Topic", "group_name": "support-team"}'

メモ

  • API ユーザーは必ず割り当て権限を持っている必要があります (割り当てが許可されたグループに属していること)
  • target_type: "Post" と投稿 ID を使用して、個々の投稿に割り当てることもできます

@opcourdis 上記の Node.js の例は正しいようです!:+1:

「いいね!」 2