6

I know that we can map an object using _method(@RequestBody ObjectClass obj).

What i'm trying to achieve is _method(@RequestBody ObjectClass obj, @RequestBody OtherObjectClass obj2) but doesn't work.

Is there some way to map two objects using same request?

Thanks!

Pedro Silva
  • 410
  • 1
  • 4
  • 15

1 Answers1

4

A HTTP request is made up of headers and body. For a single request, you have a single request body, you can't have two. You can then parse the request body to extract different variables from it, for example if your request body is a JSON, then you can parse it and convert it into an object.

See this example, further on at section "Passing multiple json objects"

evilpenguin
  • 5,210
  • 6
  • 38
  • 48