I am trying to send a POST request using Spring's RestTemplate functionality but am having an issue sending an object. Here is the code I am using to send the request:
RestTemplate rt = new RestTemplate();
MultiValueMap<String,Object> parameters = new LinkedMultiValueMap<String,Object>();
parameters.add("username", usernameObj);
parameters.add("password", passwordObj);
MyReturnObj ret = rt.postForObject(endpoint, parameters, MyRequestObj.class);
I also have a logging interceptor so I can debug the input parameters and they are almost correct! Currently, the usernameObj and passwordObj parameters appear as such:
{"username":[{"testuser"}],"password":[{"testpassword"}]}
What I want them to look like is the following:
username={"testuser"},password={"testpassword"}
Assume that usernameObj and passwordObj are Java objects that have been marshalled into JSON.
What am I doing wrong?