I call my https REST APi that calls http api on another server using Postman, and it returns 502 bad gateway error. Authentication for https API is set in a header and accept:application/json as well. All other https rest apis that not calling ohter http apis on remote server works fine.
I've created REST APIs with authentication using SpringBoot. There are GET and POST methods. They all have URL like https://.... Before calling them, user has to get a security token. Those Rest apis are available as war file residing on Server_1 deployed in tomcat. From a number of the APIs, I call another Rest services residing as jar file on another Server_2 and its URL has a URL like http://.... When I call one https rest api residing in war file on Server_1, the request goes through to Server_2. Http rest api on Server_2 answers with the JSON file. I can see it in the logs of Server_2, plus I've captured the http traffic between servers. It looks like http rest api receives the request and sends the answer back, but then https RestApi from Server_1 rejects the answer because it's not encrypted and gives bad gateway 502 error. If there is any way to fix this error?
//This is how I call http rest api on server 2. This code is part of https rest api on Server 1(war file in tomcat)
public ResponseEntity<String> function()
{
RestTemplate restTemplate = new RestTemplate();
String myUrl = "http://xxxxxx:8081";
ResponseEntity<String> response = restTemplate.getForEntity(myUrl + "/api/test/suspend/12", String.class);
return responce
}