Pet Create

user pk값에 대응하는 유저가 자신의 pet object를 생성합니다.

URL

/profile/<user_pk>/pets/

Method

POST

Headers Key Headers Value 설명 Required
Authorization Token 321*************************** 로그인에서 획득한 Token값 입력 True

Input data

Key Description Value Type Required
name 펫 이름 String True
birth_date 생년월일 YYYY-MM-DD String True
gender 성별 male/female String True
body_color 개체 색깔 white/black/brown/gold String True
species 종류 PetSpecies object에서 정의된 PetSpecies 종류 문자열
(dog/cat)
String True
breeds 품종 PetBreeds object에서 정의된 PetBreed 종류 문자열
(시츄, 골든 리트리버, 코리안 숏헤어, 페르시안)
String True
identified_number 동물등록번호 String False
is_neutering 중성화 수술 여부 Boolean default=False
image 프로필 이미지 Image File (jpg, jpeg, png, gif...) Image false

Success Response

HTTP Status code

201

Content

{
    "owner": {
        "pk": 9,
        "user_type": "d",
        "email": "[email protected]",
        "nickname": "하하하",
        "is_active": true,
        "date_joined": "2017-11-28T20:42:48.208291+09:00"
    },
    "pet": {
        "pk": 126,
        "species": "강아지",
        "breeds": "골든 리트리버",
        "name": "냠냠이",
        "birth_date": "2015-01-01",
        "gender": "male",
        "body_color": "gold",
        "identified_number": "",
        "is_neutering": false,
        "is_active": true,
        "ages": "http://localhost:8000/profile/9/pets/126/age/"
        "image": "https://{domain}static/placeholder/placeholder_pet.png"
    }
}

Error Response

HTTP Status code

400

Content

# 필드를 입력하지 않았을 경우
{
    "name": [
        "This field may not be blank."
    ],
    "birth_date": [
        "Date has wrong format. Use one of these formats instead: YYYY[-MM[-DD]]."
    ],
    "gender": [
        "\"\" is not a valid choice."
    ],
    "body_color": [
        "\"\" is not a valid choice."
    ],
    "species": [
        "This field may not be null."
    ],
    "breeds": [
        "This field may not be null."
    ]
}
# 로그인하지 않은 유저가 접근했을 경우 (토큰이 없는 경우)
{
    "detail": "You do not have permission to perform this action."
}

HTTP Status code

401 Unauthorized

# 다른 유저가 접근했을 경우 (토큰이 일치하지 않는 경우)
{
    "detail": "Invalid token."
}

HTTP Status code

413 Request Entity Too Large

Content

/*1MB  이상의 이미지가 업로드될 경우 */
<html>
    <head>
        <title>413 Request Entity Too Large</title>
    </head>
    <body bgcolor="white">
        <center>
            <h1>413 Request Entity Too Large</h1>
        </center>
        <hr>
        <center>nginx/1.12.1</center>
    </body>
</html>

results matching ""

    No results matching ""