Repository navigation
Expand file tree
/
Copy pathrequests.http
More file actions
267 lines (183 loc) · 5.2 KB
/
Copy pathrequests.http
File metadata and controls
267 lines (183 loc) · 5.2 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
GET http://localhost:5144/
###
# Minimal API routing examples
### Update the root resource
PUT http://localhost:5144/
### Delete the root resource
DELETE http://localhost:5144/
### Post to the root resource
POST http://localhost:5144/
### Bind route parameters
GET http://localhost:5144/users/123/posts/some-text
### Apply an integer route constraint
GET http://localhost:5144/products/5
### Bind an optional route parameter
GET http://localhost:5144/report/2023
### Bind query parameters
GET http://localhost:5144/search?q=sample&page=1
### Match a catch-all file path
GET http://localhost:5144/files/samplefile
### Match optional and catch-all store parameters
GET http://localhost:5144/store/electronics/123/some/extra/path
### Match the store route with an omitted optional parameter
GET http://localhost:5144/store/electronics/1234/
### Blog controller: get all blogs
GET http://localhost:5144/api/blogs
### Blog controller: get a blog by ID
GET http://localhost:5144/api/blogs/1
### Blog controller: create a blog
POST http://localhost:5144/api/blogs
Content-Type: application/json
{
"title": "Following Blog Post",
"content": "This is the content of the new blog post."
}
### Blog controller: update a blog
PUT http://localhost:5144/api/blogs/1
Content-Type: application/json
{
"title": "Updated Blog Post",
"content": "This is the updated content of the blog post."
}
### Blog controller: delete a blog
DELETE http://localhost:5144/api/blogs/2
### Product controller: get all products
GET http://localhost:5144/api/products
### Product controller: get a product by ID
GET http://localhost:5144/api/products/1
### Product controller: create a product
POST http://localhost:5144/api/products
Content-Type: application/json
{
"name": "Monitor",
"description": "27-inch display",
"price": 249.99
}
### Product controller: update a product
PUT http://localhost:5144/api/products/1
Content-Type: application/json
{
"name": "Updated Laptop",
"description": "Updated description",
"price": 1099.99
}
### Product controller: delete a product
DELETE http://localhost:5144/api/products/1
### Product controller: verify the product was deleted
GET http://localhost:5144/api/products/1
#### Error handling controller: test global exception handling
// GET http://localhost:5144/api/ErrorHandling/global-test
### Serialization: manual JSON
GET http://localhost:5144/serialization/manual-json
###
### Serialization: custom JSON with snake_case
GET http://localhost:5144/serialization/custom-json
###
### Serialization: built-in TypedResults.Json
GET http://localhost:5144/serialization/json
###
### Serialization: automatic JSON
GET http://localhost:5144/serialization/auto
###
### Serialization: XML
GET http://localhost:5144/serialization/xml
### Serialization: binary
POST http://localhost:5144/serialization/binary
### Deserialization: automatic JSON
POST http://localhost:5144/deserialization/auto
Content-Type: application/json
{
"userName": "Alice",
"userAge": 30
}
###
### Deserialization: JSON without optional age
POST http://localhost:5144/deserialization/auto
Content-Type: application/json
{
"userName": "Alice"
}
###
### Deserialization: JSON missing required username
POST http://localhost:5144/deserialization/auto
Content-Type: application/json
{
"userAge": 30
}
###
### Deserialization: explicit JSON
POST http://localhost:5144/deserialization/json
Content-Type: application/json
{
"userName": "Alice",
"userAge": 30
}
###
### Deserialization: JSON with extra field
POST http://localhost:5144/deserialization/json
Content-Type: application/json
{
"userName": "Alice",
"userAge": 30,
"favoriteFurnace": 64
}
###
### Deserialization: custom options rejects extra fields
POST http://localhost:5144/deserialization/custom-options
Content-Type: application/json
{
"userName": "Alice",
"userAge": 30,
"favoriteFurnace": 64
}
###
### Deserialization: wrong data type
POST http://localhost:5144/deserialization/json
Content-Type: application/json
{
"userName": "Alice",
"userAge": "buffalo"
}
###
### Deserialization: XML
POST http://localhost:5144/deserialization/xml
Content-Type: application/xml
<DeserializationSample>
<UserName>Alice</UserName>
<UserAge>30</UserAge>
</DeserializationSample>
###
### Serialization: binary
POST http://localhost:5144/serialization/binary
### Deserialization: binary
GET http://localhost:5144/deserialization/binary
### Deserialization: validated data
POST http://localhost:5144/deserialization/validated
Content-Type: application/json
{
"userName": "Dana",
"userAge": 30
}
### Deserialization: validated data with errors
POST http://localhost:5144/deserialization/validated
Content-Type: application/json
{
"userName": "",
"userAge": -10
}
###
### Serialization security: validated user
POST http://localhost:5144/security/serialize-user
Content-Type: application/json
{
"name": "Alice",
"email": "alice@example.com",
"password": "SecureP@ss123"
}
###
### Middleware: allow the request through
GET http://localhost:5144/middleware/pass
### Middleware: stop before reaching the endpoint
GET http://localhost:5144/middleware/blocked
### HTTP logging: unknown endpoint
GET http://localhost:5144/this-route-does-not-exist