79597774

Date: 2025-04-29 07:02:53
Score: 1.5
Natty:
Report link

Ideally, complex objects need to be sent through @postmapping, as shown below

@PostMapping("/quotes")
void getQuotes(@RequestBody QuoteRequest request) {}

But if you really want to send the data in the get request as mentioned in the other comment the url has to be http:// localhost : 8080/api/v1/quotes?topics[]= ... again with this since the spring cannot parse the data you need to parse the data, may be using ObjectMapper as shown below

@GetMapping("/quotes")
void getQuotes(@RequestParam ("topics") String topics) throws JsonProcessingException {
    ObjectMapper mapper = new ObjectMapper();
    List<Topic> topicList = mapper.readValue(topics, new TypeReference<List<Topic>>() {});
    //your logic..
}

then if you do send the request in the swagger like this { "topics": [{ "name": "test", "amount": 0 }] } it will work.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • User mentioned (1): @postmapping
  • Low reputation (1):
Posted by: Sasirekha Kumaran