How can I send a POST
request to the application itself?
If I just send a relative post request: java.lang.IllegalArgumentException: URI is not absolute
.
@RestController
public class TestServlet {
@RequestMapping("value = "/test", method = RequestMethod.GET)
public void test() {
String relativeUrl = "/posting"; //TODO how to generate like "localhost:8080/app/posting"?
new RestTemplate().postForLocation(relativeUrl, null);
}
}
So using the example above, how can I prefix the url with the absolute server url path localhost:8080/app
? I have to find the path dynamically.