How to send POST-request with request arguments using cURL? How to send POST-request with request arguments using cURL? curl curl

How to send POST-request with request arguments using cURL?


Analysis

Long story short, conceptually, @RequestParam and @RequestBody are mutually exclusive: query parameters (@RequestParam) are sent as a request body.

Please see the additional details here:

Solution

Currently, there are two alternatives:

  1. Stick to the request parameters (@RequestParam) only: pass every parameter (i.e. every JSON property) as a query parameter.
  2. Stick to the request body (@RequestBody) only, for example:

    1. Pass everything as a JSON request body.
    2. Pass everything as a JSON request body, except the user_id parameter. The parameter may be made @PathVariable and the @RequestMapping should use the appropriate placeholder to reference it.