-
Notifications
You must be signed in to change notification settings - Fork 3
api_response_code
choisungwook edited this page Oct 6, 2021
·
3 revisions
- API Http ์๋ต ์ฝ๋
- ํ์ ์กฐํ ๋ฑ ๋ฐ์ดํฐ ์กฐํ ์๋ต์ 200(Ok)
- ๋ง์ฝ ๋ฐ์ดํฐ๊ฐ ์๋ค๋ฉด 404(Not found)
- ์คํจํ๋ค๋ฉด 500(Internal Server error)
HTTP/1.1 200 OK
{
"name": "testuser"
}
- ํ์ ๋ฑ๋ก ๋ฑ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๋ฐ์ดํฐ๋ฅผ ์์ฑ์ด ์ฑ๊ณตํ 201(Created)
- ์ฌ์ ๊ฐ ๋๋ค๋ฉด ์๋ต ํค๋ Locationํ๋์ ์กฐํํ ์ ์๋ API์ฃผ์ ์ถ๊ฐ
- location: /users/1
- ์ฌ์ ๊ฐ ๋๋ค๋ฉด ์๋ต ํค๋ Locationํ๋์ ์กฐํํ ์ ์๋ API์ฃผ์ ์ถ๊ฐ
- ์คํจํ๋ค๋ฉด 500(Internal Server error)
HTTP/1.1 201 Created
{
"id": 1,
"name": "testuser"
}
- ํ์ ์์ ๋ฑ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๋ฐ์ดํฐ๋ฅผ ์์ ์ด ์ฑ๊ณตํ ๊ฒฝ์ฐ 200(Ok)
- ์์ ํ ๋ฐ์ดํฐ๊ฐ ์๋ค๋ฉด 404(Not found)
- ์คํจํ๋ค๋ฉด 500(Internal Server error)
HTTP/1.1 200 OK
{
"name": "testuser"
}
- ํ์ ์ญ์ ๋ฑ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์ญ์ ๊ฐ ์ฑ๊ณตํ ๊ฒฝ์ฐ 204(No Content)
- ํ๋ก ํธ ๊ฐ๋ฐ์์ ํ์ํ์ฌ ์๋ต ๋ฐ์ดํฐ ์์ฑํ ์๋ ์์
- ์์ ํ ๋ฐ์ดํฐ๊ฐ ์๋ค๋ฉด 404(Not found)
- ์คํจํ๋ค๋ฉด 500(Internal Server error)
HTTP/1.1 204 No Content
{
}
- request body์ ํ๋๋ฅผ ๋นผ๋จน๊ฑฐ๋ ํ๋ ์๋ฃํ์ด ๋ง์ง ์๋ ๊ฒฝ์ฐ 400(Bad Request)
- response body์ ์๋ฌ ๋ด์ฉ ์ ๋ฌ
HTTP/1.1 400 Bad Request
{
"error_messages": [
"name ํ๋๊ฐ ์์ต๋๋ค"
]
}
- ์์ฒญ์ jwtํ ํฐ์ด ํ์ํ๋ฐ ์์ฒญ์ jwtํ ํฐ์ด ์๋ค๋ฉด 401(Unauthorized)
- api๋ฅผ ์คํํ ๊ถํ์ด ์์ผ๋ฉด 403(Forbidden)