API를 통해 할당하는 방법이 있을까요? 문서에서는 찾지 못했지만, 반가운 놀라움을 안겨주길 바랍니다 ![]()
수정: 직접 역공학을 해봐야 할 것 같습니다!
API를 통해 할당하는 방법이 있을까요? 문서에서는 찾지 못했지만, 반가운 놀라움을 안겨주길 바랍니다 ![]()
수정: 직접 역공학을 해봐야 할 것 같습니다!
우선, 우리의 목표는 안정적인 API를 갖추는 것입니다. 이를 달성하기 위해서는 수년에 걸친 노력이 필요하지만, 분명히 도달하고자 하는 방향입니다.
그동안 사용할 수 있는 합리적인 2025년의 팁은 AI 에이전트를 활용해 이러한 문제를 스스로 파악하도록 하는 것입니다:
이것은 GitHub 헬퍼를 활용해 질문에 답하는 방법을 보여줍니다!
https://meta.discourse.org/discourse-ai/ai-bot/shared-ai-conversations/TlirMaHlES3vbu50DAC1GQ
해결하셨나요? 그렇다면 여기서 배운 내용을 공유해 주실 수 있나요?
안녕!
아직은 아니야! 이 프로젝트는 더 시급한 일 때문에 보류됐지만, 다음 주에 다시 진행할 거야 ![]()
@tobiaseigen 저는 node js를 사용하면서 이 방법으로 작동합니다
var https = require(‘https’);
// Configuration
var CONFIG = {
apiUrl: ‘YOURDISCOURSEDOMAIN’,
apiKey: ‘YOURAPIKEY’,
apiUsername: ‘YOURAPIUSER’,
assignToUsername: ‘USERNAMETOASSIGNTO’ // Username to assign topics to
};
// Topic IDs to assign
var topicIds = [634]; //change with the topic id
function assignTopic(topicId, callback) {
var postData = JSON.stringify({
target_id: topicId,
target_type: ‘Topic’,
username: CONFIG.assignToUsername
});
var options = {
hostname: CONFIG.apiUrl,
port: 443,
path: ‘/assign/assign.json’,
method: ‘PUT’,
rejectUnauthorized: false,
headers: {
‘Api-Key’: CONFIG.apiKey,
‘Api-Username’: CONFIG.apiUsername,
‘Content-Type’: ‘application/json’,
‘Content-Length’: postData.length
}
};
var req = https.request(options, function(res) {
var data = ‘’;
res.on('data', function(chunk) {
data += chunk;
});
res.on('end', function() {
console.log('Status:', res.statusCode);
console.log('Raw response:', data);
try {
var response = JSON.parse(data);
if (res.statusCode === 200) {
console.log('Topic ' + topicId + ' successfully assigned');
} else {
console.log('Topic ' + topicId + ' error:', response.errors || response.error_type || response);
}
} catch (e) {
console.log('Parse error:', e.message);
}
if (callback) callback();
});
});
req.on(‘error’, function(e) {
console.error('Request error for topic ’ + topicId + ‘:’, e);
if (callback) callback();
});
req.write(postData);
req.end();
}
// Run sequentially
var index = 0;
function next() {
if (index < topicIds.length) {
assignTopic(topicIds[index], function() {
index++;
setTimeout(next, 500);
});
}
}
console.log(‘Assigning topics:’, topicIds.join(‘, ‘));
console.log(‘Assign to:’, CONFIG.assignToUsername);
console.log(’’);
next();
Discourse Assign 에서 다음 API 엔드포인트를 제공합니다:
/assign/assign.json)필수 매개변수:
target_id - 대상 주제 또는 게시물 IDtarget_type - "Topic" 또는 "Post"다음 중 하나:
username - 할당할 사용자 이름group_name - 할당할 그룹 이름선택적 매개변수:
note - 할당 메모status - 할당 상태should_notify - 알림 전송 (기본값: true)/assign/unassign.json)필수 매개변수:
target_id - 대상 주제 또는 게시물 IDtarget_type - "Topic" 또는 "Post"# 주제 123을 사용자 "john"에게 할당
# Assign topic 123 to user "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"}'
# 대신 그룹에 할당
# Assign to a group instead
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"}'
참고
@opcourdis 위의 Node.js 예시는 올바르게 보입니다! ![]()
공유해 주셔서 감사합니다. 모든 파라미터를 포함할 수 있다는 것을 보니 좋습니다.