Topic Create

입력한 데이터로 Topic object를 생성합니다.

URL

/topic/

Method

POST

Data Params

Key Description Type Require
name Topic의 이름 - Unique=True Str True
image Topic에 대한 이미지 - 업로드된 이미지는 200x200으로 Thumbnail화 File False
description Topic에 대한 설명 Str False

Name 필드 Unique=True:

DB상에 Name은 한가지만 존재할 수 있습니다. 존재하는 Name에 대해 Create가 실행되려 하면 400 Error가 반환됩니다.

Image Thumbnail

업로드되는 Image는 현재는 일괄적으로 중앙에 초점을 맞추어 200x200으로 Thumbnail화 됩니다. - 추후 변경 가능

Success Response

HTTP Status Code

201

Content

Key Description Type
pk Topic의 pk Int
url 생성된 Topic Detail 페이지의 링크 str
creator Topic을 만든 유저의 Profile Detail 링크 Int
name Topic의 이름 Str
description Topic에 대한 설명 Str
image Topic에 대한 썸네일 사진으로의 링크 Str
answer_count Topic에 대한 답변 개수 Int
question_count Topic에 대한 질문 개수 Int
expert_count Topic에 대한 전문가 Follower 수 Int
interest_count Topic에 대한 관 Follower 수 Int
created_at 생성된 날짜 Date
modified_at 마지막으로 수정된 날짜 - 처음 생성되었을 때는 created_at과 같음 Date
{
    "pk": 99,
    "url": "http://localhost:8000/topic/99/",
    "creator": "http://localhost:8000/user/1/profile/",
    "name": "분자학",
    "description": "",
    "image": "topic/99/background.png",
    "answer_count": 0,
    "question_count": 0,
    "expert_count": 1,
    "interest_count": 1,
    "created_at": "2017-12-12T15:48:37.180863+09:00",
    "modified_at": "2017-12-12T15:48:37.194514+09:00"
}

Error Response

Bad Request Error

HTTP Status Code

400

Content

# name 중

{
    "error":"이미 존재하는 Topic 이름입니다."
}

Bad Request Error

HTTP Status Code

400

Content

# 파일이 Image가 아닐 경우

{
    "image": [
        "유효한 이미지 파일을 업로드 하십시오. 업로드 하신 파일은 이미지 파일이 아니거나 손상된 이미지 파일입니다."
    ]
}

results matching ""

    No results matching ""