CRUD API Application - Events Creation Page
Read All Records
Sample Request
$ curl --request GET --url 'https://utils.diveintohacking.com/api/v1/events?token=token123'
Sample Response
[
{
id: 1,
title: "Let's have an event 1!",
body: "This is the body for event 1."
},
{
id: 2,
title: "Let's have an event 2!",
body: "This is the body for event 2."
}
]
Read a Record
Sample Request
$ curl --request GET --url 'https://utils.diveintohacking.com/api/v1/events/1?token=token123'
Sample Response
{
"id":1,
"title":"event 1",
"body":"body for event 1"
}
Create a Record
Sample Request
$ curl --request POST \
--url 'https://utils.diveintohacking.com/api/v1/events?token=token123' \
--header 'Content-Type: application/json' \
--data '{
"title": "event 11",
"body": "body for event 11"
}'
Sample Response
{
"id": 11,
"title": "event 11",
"body": "body for event 11"
}
Update a Record
Sample Request
$ curl --request PUT \
--url 'https://utils.diveintohacking.com/api/v1/events/5?token=token123' \
--header 'Content-Type: application/json' \
--data '{ "title": "changed title", "body": "changed body" }'
Sample Response
{
"id": 5,
"title": "changed title",
"body": "changed body"
}
Delete a Record
Sample Request
$ curl --request DELETE \
--url 'https://utils.diveintohacking.com/api/v1/events/10?token=token123' \
--header 'Content-Type: application/json'
Sample Response
{
"id": 10,
"title": "Let's have an event 10!",
"body": "This is the body for event 10."
}