I have a server and a client. I am using Spring to map http requests on the server and RestTemplate to make requests to the server.
Server code looks like this:
@RequestMapping (value="/someEndPoint", method = RequestMethod.POST)
@ResponseBody
public String configureSettings(
@RequestParam(required=false) Integer param1,
@RequestParam(required=false) Long param2,
@RequestBody String body)
{
if(param1 != null)
// do something
if(body not empty or null)
//do something
}
Client side:
String postUrl = "http://myhost:8080/someEndPoint?param1=val1"
restTemplate.postForLocation(postUrl, null);
This works in that the correct action is triggered on the server side from param1
however, the body of the request also contains:
param1=val1
The request body when it is set it will json so all I want is to be able to set other parameters without setting the body.
I know I am using the restTemplate incorrectly so any help would be greatly appreciated.