InterestFollowRelation Create

"관심분야 주제 팔로우"

로그인한 사용자를 user로 가지고, Client에서 보낸 데이터의 pk에 해당하는 주제를 topic으로 가지는 InterestFollowRelation(유저-관심주제 팔로우 관계) object을 생성합니다.

URL

/user/topic-interest-follow-relation/

Method

POST

Header

Key Value
Authorization Token(로그인 성공했을 때 받은 Token key값)

Data Params

Key Description Type Require
topics 팔로우할 주제의 pk(primary key)를 담은 리스트 List True

1. 주제 1개 팔로우 시 보낼 data: {'topics': ['1']}

2. 주제 여러개를 팔로우 할 시(초기 주제 설정) 보낼 data: {'topics': ['1', '2', '3', ...]}

Success Response

201 Created

HTTP Status Code

201

[
    {
        # 생성한 InterestFollowRelation object의 pk
        # 언팔로우를 할 때, 해당 pk를 URI에 담아서 DELETE 요청을 보내야 함 
        "follow_relation_pk": 10,
        # 팔로우하는 유저
        "user": 3,
        # 팔로우받는 주제
        "topic": 1
    },
    {
        "follow_relation_pk": 11,
        "user": 3,
        "topic": 2
    },
    {
        "follow_relation_pk": 12,
        "user": 3,
        "topic": 3
    },

    ...
    ...
]

Error Response

Bad Request Error

HTTP Status Code

400

Content

# 필수 항목 누락
{
    "topic": [
        "이 필드는 필수 항목입니다."
    ]
}

Bad Request Error

HTTP Status Code

400

Content

# 존재하지 않는 topic을 팔로우하려 한 경우
{
    "topic": [
        "유효하지 않은 pk \"2\" - 객체가 존재하지 않습니다."
    ]
}

Bad Request Error

HTTP Status Code

400

Content

# 이미 팔로우한 topic을 팔로우하려 한 경우
{
    "topic": [
        "이미 팔로우하고 있는 주제입니다."
    ]
}

Unauthorized Error

HTTP Status Code

401

Content

# 유저 Token을 헤더에 담지 않고 요청을 보낸 경우

{
    "detail": "자격 인증데이터(authentication credentials)가 제공되지 않았습니다."
}

Unauthorized Error

HTTP Status Code

401

Content

# 존재하지 않는 유저 Token을 헤더에 담아 요청을 보낸 경우

{
    "detail": "토큰이 유효하지 않습니다."
}

results matching ""

    No results matching ""