|
|
|
|
233
|
-
|
233
|
-
|
234
|
# Part 3.1.8 - Test
|
234
|
# Part 3.1.8 - Test
|
235
|
* Restart the QuickPoll application.
|
235
|
* Restart the QuickPoll application.
|
236
|
-* Use Postman to execute a `PUT` to `http://localhost:8080/polls/1` whose request body is the `JSON` file below.
|
|
|
|
|
236
|
+* Use Postman to execute a `PUT` to `http://localhost:8080/polls/1` whose request body is the `JSON` object below.
|
237
|
* You can modify the request body in Postman by navigating to the `Body` tab, selecting the `raw` radio button, and selecting the `JSON` option from the text format dropdown.
|
237
|
* You can modify the request body in Postman by navigating to the `Body` tab, selecting the `raw` radio button, and selecting the `JSON` option from the text format dropdown.
|
238
|
|
238
|
|
239
|
```JSON
|
239
|
```JSON
|
|
|
|
|
266
|
public ResponseEntity<?> createVote(@PathVariable Long pollId, @RequestBody Vote
|
266
|
public ResponseEntity<?> createVote(@PathVariable Long pollId, @RequestBody Vote
|
267
|
vote) {
|
267
|
vote) {
|
268
|
vote = voteRepository.save(vote);
|
268
|
vote = voteRepository.save(vote);
|
269
|
-// Set the headers for the newly created resource
|
|
|
|
|
269
|
+ // Set the headers for the newly created resource
|
270
|
HttpHeaders responseHeaders = new HttpHeaders();
|
270
|
HttpHeaders responseHeaders = new HttpHeaders();
|
271
|
responseHeaders.setLocation(ServletUriComponentsBuilder.
|
271
|
responseHeaders.setLocation(ServletUriComponentsBuilder.
|
272
|
fromCurrentRequest().path("/{id}").buildAndExpand(vote.getId()).toUri());
|
272
|
fromCurrentRequest().path("/{id}").buildAndExpand(vote.getId()).toUri());
|