In my Spring Boot project I must have a postmapping which has a JSON in request body:
@PostMapping(value = "/cloudapi/**")
public String postCloud(HttpServletRequest request,
HttpServletResponse response,
Model model) {
String[] urlparts = request.getRequestURI().split("/cloudapi");
String urltail = "";
if (urlparts.length > 1)
urltail = urlparts[1];
return "rango:8075/cloudapi" + urltail;
}
postCloud(...)
method should forward the request to an external URL("rango:8075/cloudapi"). The problem is it is losing its body when redirect.
JSON in request body:
{
"sm": -12,
"customerid": "asd123"
}
Content-Type is application/json.
Server port from application.properties:
server.port=8081
How can I save the request body while I forward it? Or is it possible to set that JSON as request body when redirect to an external URL?