-
-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathGettingStarted.http
More file actions
85 lines (64 loc) · 1.54 KB
/
GettingStarted.http
File metadata and controls
85 lines (64 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
@hostAddress = http://localhost:14141
### Get all books with their authors.
GET {{hostAddress}}/api/books?include=author
### Get the first two books.
GET {{hostAddress}}/api/books?page[size]=2
### Filter books whose title contains whitespace, sort descending by publication year.
GET {{hostAddress}}/api/books?filter=contains(title,'%20')&sort=-publishYear
### Get only the titles of all books.
GET {{hostAddress}}/api/books?fields[books]=title
### Get the names of all people.
GET {{hostAddress}}/api/people?fields[people]=name
### Create a new person.
POST {{hostAddress}}/api/people
Content-Type: application/vnd.api+json
{
"data": {
"type": "people",
"attributes": {
"name": "Alice"
}
}
}
### Create a new book, authored by the created person.
POST {{hostAddress}}/api/books
Content-Type: application/vnd.api+json
{
"data": {
"type": "books",
"attributes": {
"title": "Getting started with JSON:API",
"publishYear": 2000
},
"relationships": {
"author": {
"data": {
"type": "people",
"id": "4"
}
}
}
}
}
### Change the publication year and author of the book with ID 1.
PATCH {{hostAddress}}/api/books/1
Content-Type: application/vnd.api+json
{
"data": {
"type": "books",
"id": "1",
"attributes": {
"publishYear": 1820
},
"relationships": {
"author": {
"data": {
"type": "people",
"id": "4"
}
}
}
}
}
### Delete the book with ID 1.
DELETE {{hostAddress}}/api/books/1