안녕하세요,
기존 앱에서 데이터를 새로운 Discourse로 가져오는 작업 중입니다.
아래 API 호출을 사용하면 카테고리와 그 설명을 함께 생성할 수 없습니다:
curl -X POST "https://site-discourse/categories.json" \
-H "Api-Key: api-key" \
-H "Api-Username: api-username" \
-d "name=categorie test" \
-d "description=Description De La Categorie"
카테고리는 생성되지만 설명이 없습니다.
다음과 같은 응답을 받습니다:
{"category":{"id":21,"name":"categorie test",[...],"slug":"categorie-test", [...] **,"description":null**,"description_text":null,"description_excerpt":null,"topic_url":"/t/a-propos-de-la-categorie-categorie-test/12286", [...]
도움 주셔서 감사합니다.
Canapin
(Coin-coin le Canapin)
2
안녕하세요 
카테고리 설명은 자동으로 생성된 “About” 주제의 내용입니다. 기본 텍스트는 편집될 때까지 "null"로 간주되는 것 같습니다.
카테고리를 생성하는 요청에는 사용 가능한 “description” 매개변수가 없는 것 같으며, About 주제의 첫 번째 게시글을 업데이트하려면 별도의 API 요청을 보내야 합니다.
수입 과정에 따라 API를 사용하는 대신 적절한 가져오기 스크립트를 사용하는 것이 더 적합할 수 있습니다. #support:migration을 참고해 주세요.
답변해 주셔서 감사합니다
카테고리를 생성한 후 해당 카테고리의 설명을 수정할 수 있도록 다음 스크립트를 작성했습니다:
curl -X POST "https://site-discourse/categories.json" \
-H "Api-Key: api-key" \
-H "Api-Username: api-username" \
-d "name=Catégorie 1"
sleep 2
latest_posts_response=$(curl -X GET "https://site-discourse/posts.json" \
-H "Content-Type: application/json" \
-H "Api-Key: api-key" \
-H "Api-Username: api-username")
post_id=$(echo $latest_posts_response | jq '.latest_posts[0] .id')
curl -X PUT "https://site-discourse/posts/$post_id.json" \
-H "Content-Type: application/json" \
-H "Api-Key: api-key" \
-H "Api-Username: api-username" \
-d '{
"post": {
"raw": "Description de la catégorie 1"
}
}'