1

Any one can help. How I can pass below value as a request parameter. here data is key remaining values as parameters and how I can read these request value in my controller class. I am using spring with RestClient webservices.

"data" : [ { "key" : "Hi", "value": "true" } ]
M. Deinum
  • 115,695
  • 22
  • 220
  • 224
Java Learing
  • 269
  • 3
  • 11
  • 26
  • 1
    Try to PUT it with additional braces like: ```{"data" : [ { "key" : "Hi", "value": "true" } ]}``` and header ```Content-Type: application/json```. In controller method arguments add @RequestBody Map map. – Mati Apr 02 '15 at 09:58
  • I s it possible to send as get method with this value as request parameter to the controller class...? – Java Learing Apr 02 '15 at 10:06
  • how I can pass "data" value as a request(ex: url?name='java') same like i need to pass(url?data="how I can pass kay ,value like map ")...Can any one help.. – Java Learing Apr 02 '15 at 10:28
  • You can get query parameters by controller method argument like ```@RequestParam(value="name") String name```. – Mati Apr 02 '15 at 10:48
  • A workaround: https://stackoverflow.com/questions/33581329/map-parameter-as-get-param-in-spring-rest-controller – Ralph May 24 '21 at 08:07

2 Answers2

1

You can't. You can pass it in the POST body as JSON and marshall it as required. Request Parameters must be appended to the URL in the usual format

Steve
  • 363
  • 2
  • 11
0

Post Request ex:

"key":{
          "fullName":"FirstName LastName",
          "number":"1234",
          "age":"21"
    },

in model class we have to declare like:

 private Map<String, Object> key;
Java Learing
  • 269
  • 3
  • 11
  • 26