Requests to endpoints requiring authentication should set the Authorization header to Token , where is the token received in the login response.
POST requests with a body should set the Content-Type header to application/json
.
https://questionbox-team-skywalker.herokuapp.com/auth/token/login/
POST auth/token/login/
{
"username": "admin",
"password": "somepassword"
}
200 OK
{
"auth_token": "c312049c7f034a3d1b52eabc2040b46e094ff34c"
}
https://questionbox-team-skywalker.herokuapp.com/auth/token/logout/
POST auth/token/logout/
HTTP_204_NO_CONTENT
https://questionbox-team-skywalker.herokuapp.com/auth/users/
username, first_name, last_name, email, password, re_password are required fields.
POST auth/users/
{
"username": "batman",
"first_name": "Bruce",
"last_name": "Wayne",
"email": "batman@email.com",
"password": "thisispassword",
"re_password": "thisispassword"
}
201 Created
{
"first_name": "Bruce",
"last_name": "Wayne",
"email": "batman@email.com",
"username": "batman",
"id": 8
}
https://questionbox-team-skywalker.herokuapp.com/auth/users/me
Requires authentication.
GET auth/users/me
200 OK
{
"pk": 1,
"username": "luke",
"email": "",
"questions": [
{
"pk": 1,
"title": "Do lilies require direct sun?",
"owner": "luke",
"created_at": "Sep. 15, 2021 at 07:13 PM",
"favorited_by": [
"leia",
"luke",
"anakin"
],
"answer_count": {
"id__count": 4
}
}
],
"answers": [
{
"pk": 14,
"body": "Test",
"created_at": "Sep. 19, 2021 at 09:29 PM",
"accepted": false,
"owner": "luke",
"question": "Do lilies require direct sun?",
"favorited_by": []
},
{
"pk": 13,
"body": "Test",
"created_at": "Sep. 19, 2021 at 08:43 PM",
"accepted": false,
"owner": "luke",
"question": null,
"favorited_by": []
},
{
"pk": 12,
"body": "Test",
"created_at": "Sep. 19, 2021 at 07:27 PM",
"accepted": false,
"owner": "luke",
"question": "Do lilies require direct sun?",
"favorited_by": []
}
]
}
https://questionbox-team-skywalker.herokuapp.com/api/questions/
GET api/questions/
200 OK
{
"pk": 9,
"title": "How close should bulbs be planted?",
"owner": "admin",
"created_at": "Sep. 17, 2021 at 07:24 PM",
"favorited_by": [],
"answer_count": {
"id__count": 0
}
},
{
"pk": 8,
"title": "How close should bulbs be planted?",
"owner": "admin",
"created_at": "Sep. 16, 2021 at 08:00 PM",
"favorited_by": [],
"answer_count": {
"id__count": 0
}
},
{
"pk": 7,
"title": "When should I plant tulips in PA?",
"owner": "luke",
"created_at": "Sep. 16, 2021 at 02:05 AM",
"favorited_by": [
"C3PO"
],
"answer_count": {
"id__count": 2
}
hhttps://questionbox-team-skywalker.herokuapp.com/api/questions/?search={searchterm}
Users can search and get results referencing the title and owner.
GET api/questions/?search=bulbs
200 OK
{
"pk": 9,
"title": "How close should bulbs be planted?",
"owner": "admin",
"created_at": "Sep. 19, 2021 at 11:02 PM",
"favorited_by": [],
"answer_count": {
"id__count": 0
}
},
{
"pk": 3,
"title": "How close should I plant bulbs?",
"owner": "leia",
"created_at": "Sep. 16, 2021 at 01:22 AM",
"favorited_by": [],
"answer_count": {
"id__count": 0
}
}
https://questionbox-team-skywalker.herokuapp.com/api/questions/
Title is a required field.
POST api/questions/
{
"title": "How close should bulbs be planted?",
"body": "Working on my spring garden plans."
}
201 Created
{
"pk": 8,
"title": "How close should bulbs be planted?",
"body": "Working on my spring garden plans.",
"owner": "admin",
"created_at": "Sep. 16, 2021 at 08:00 PM"
}
https://questionbox-team-skywalker.herokuapp.com/api/questions/pk/
Requires authentication.
GET api/questions/7/
200 OK
{
"pk": 7,
"title": "When should I plant tulips in PA?",
"body": "",
"owner": "luke",
"created_at": "Sep. 16, 2021 at 02:05 AM",
"favorited_by": [
"C3PO"
],
"answers": [
{
"pk": 8,
"body": "Fall is the best time to plant spring flowering bulbs. Here in Maine, that means between September and November. However, bulbs can be planted even if winter frost has appeared as long as the soil or compost is easily cultivated.",
"created_at": "Sep. 16, 2021 at 02:06 AM",
"accepted": true,
"owner": "leia",
"question": 7,
"favorited_by": [
"C3PO"
]
},
{
"pk": 9,
"body": "It's important to plant tulips at the proper time to ensure healthy growth. For USDA hardiness zones seven and below, tulip bulbs should be planted in the fall before frost arrives. For zones eight and above, plant bulbs in late December or January to see spring blooms.",
"created_at": "Sep. 16, 2021 at 02:06 AM",
"accepted": false,
"owner": "C3PO",
"question": 7,
"favorited_by": []
}
]
}
https://questionbox-team-skywalker.herokuapp.com/api/questions/pk/
Requires authentication.
Only owner can edit.
Question may not be edited after it has answers. (not functional yet, still working on it)
Title is a required field.
PUT api/questions/7/
{
"title": "updating this bby again",
"body": "Fingers crossed this works."
}
200 OK
{
"pk": 11,
"title": "updating this bby again",
"body": "Fingers crossed this works.",
"owner": "admin",
"created_at": "Sep. 21, 2021 at 10:27 AM"
}
https://questionbox-team-skywalker.herokuapp.com/api/questions/pk/
Requires authentication.
Only owner may delete.
DELETE api/questions/7/
204 No Content
https://questionbox-team-skywalker.herokuapp.com/api/answers/new
Requires authentication.
Must pass through a question's primary key.
body and question are required fields.
POST api/answers/new
{
"question": "{pk}"
"body": "Test"
}
201 Created
{
"pk": 11,
"body": "Test",
"owner": "luke",
"question": {pk},
"created_at": "Sep. 19, 2021 at 06:55 PM"
}
https://questionbox-team-skywalker.herokuapp.com/api/questions/pk/
Requires authentication.
PATCH api/questions/7/
200 OK
{
"pk": 11,
"title": "updating this bby again",
"body": "Fingers crossed this works.",
"owner": "admin",
"created_at": "Sep. 21, 2021 at 10:27 AM",
"favorited_by": [
"admin",
"luke" (Username is added to list based on token authentication)
],
"answers": []
}
https://questionbox-team-skywalker.herokuapp.com/api/answers/pk
Requires authentication.
Currently not limited by question owner to accept.
PATCH api/answers/16/
{
"accepted": true
}
200 OK
{
"pk": 16,
"body": "but I guess I am using luke",
"created_at": "Sep. 21, 2021 at 01:52 PM",
"accepted": true,
"owner": "luke",
"question": "updating this bby again and again to check, with forbidden",
"favorited_by": []
}