I am using Spring RestTemplate client to do a POST call to another application which handles this request as HTTpServletRequest. Problem is HTTpServletRequest is expecting a key value pair e.g.
String xmlString = request.getParameter("xml12")
//xmlString should be "`<parent><child></child></parent>`" but coming as null.
Here is the code snippet of both ends -
My app -
String data = "`<parent><child></child></parent>`"
HttpHeaders header = new HttpHeaders()
header.setContentType(MediaType.APPLICATION_XML)
Map<String,String> bodyParamMap = new HashMap<String,String>();
bodyParamMap.put("xml123",data)
String reqBodyData = new ObjectMapper().writeValuesAsString(bodyParamMap)
HttpEntity<String> entity = new HttpEntity<String>(reqBodyData,header)
RestTemplate rt = new RestTemplate()
String response = rt.postForObject("url",entity,String.class)
//Getting response as 500
Other app -
HttpServletRequest request = new HttpServletRequest()
String xmlString = request.getParameter("xml123")
// xmlString is null
I just want to know my mistake and how to pass my data string to post request so that request.getParameter("xml123")
receives my data xml as String.