1

Is it possible with GET Rest Method to pass collection of objects as URL parameters?

class Person{
  String name;
  String surname;
  ...
}
public ResponseEntity<List<PersonInfo>> getInfoAboutPersons(@RequestParam List<Person> persons)

I try to send JSON as string and parse it. I became: "Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986", because of '[', ']'.

My only solution is pass list of String (name,surname) and then split and convert to objects, what is not really elegance.

Can someone help by example?

9
  • 3
    No, you need to POST for that data. Commented Oct 7, 2019 at 12:27
  • 1
    Also you may consider sending the JSON string in the @RequestBody . Commented Oct 7, 2019 at 12:29
  • you should check @brian answer on this link stackoverflow.com/questions/22398892/… Commented Oct 7, 2019 at 12:30
  • @NavinGelot Ok, but how to call it in postman? Commented Oct 7, 2019 at 12:33
  • I think you could URLEncode your URL String, although the correct way to do it is using POST instead of GET. Commented Oct 7, 2019 at 12:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.