I have an angular client that makes a POST call on my server. This server should receive a response by calling another server (server2) with a POST call and transmit the response from server2 to the client. I have tried the following approaches.
public Response call(){
String server2Url = "http://server2/path"
RestClient restClient = new RestClient();
return Response.fromResponse(restClient.post(server2Url)).build();
}
But in the above case, the HTTP status code is transmitted, but not the response body. The response body is empty.
Then I tried:
public Response call() throws URISyntaxException{
String server2Url = "http://server2/path"
RestClient restClient = new RestClient();
return Response.temporaryRedirect(new URI(server2Url)).build();
}
but the browser client ends the OPTIONS call on server2Url instead of POST
and i tried.
public Response call() throws URISyntaxException{
String server2Url = "http://server2/path"
RestClient restClient = new RestClient();
return Response.seeOther(new URI(server2Url)).build();
}
but this leads to a GET call instead of a POST.
How to make browser client POST call for server2
source
share