callicoder/spring-security-react-ant-design-polls-app

Issues testing the create poll api in postman

Kordedekehine opened this issue · 2 comments

As a beginner,I've been coding along the tutorial until I finished and I realize I can't test the create poll API.

The PollRequest class
@DaTa
public class PollRequestDto {

private String question;


private List<ChoiceRequestDto> choices;


private PollLengthOfTimeDto pollLength;

}

The choices class

@DaTa
public class ChoiceRequestDto {

private String opinion;

}

The pollLenght class

@DaTa
@NoArgsConstructor

public class PollLengthOfTimeDto {

private Integer days;


private Integer hours;

}

These is the controller code:

@PostMapping
//@PreAuthorize("hasRole('USER')")
public ResponseEntity<?> createPoll(@Valid @requestbody PollRequestDto pollRequest) {
Poll poll = pollService.createPoll(pollRequest);

    URI location = ServletUriComponentsBuilder
            .fromCurrentRequest().path("/{pollId}")
            .buildAndExpand(poll.getId()).toUri();

    return ResponseEntity.created(location)
            .body(new ApiResponse(true, "Poll Created Successfully"));
}

And these is how I've been testing it in the postman:
Screenshot (166)

Can someone help me with this question? I can't send out the PollLength request. It's not working

SOLVED

{
"question": "Who is the next president of the country",
"choices": [
{
"opinion": "buhari"
},
{
"opinion": "atiku"
},
{
"opinion": "obi"
}
],
"pollLength": {
"days": 2,
"hours": 2
}

}