I can't find any documentation or I'm just getting it wrong while searching.
How can I call a rest api example : http://192.168.1.123:1106/idauthenticator/listoffullname
That API is accepting array of uids example: List of uids (Body request) with response entity of (firstname, lastname, uid)
How can I call that API with an ArrayList of uid so that I can get a response from that API.
BTW that api is getting all the fullname according to uids.
This is my get API of listoffullname with requestbody of list uids.
@GetMapping(path = "/listoffullname", produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<ListOfFullname> getFullname(
@RequestHeader Map<String, String> headers,
@RequestBody List<Uids> listofuid) throws URISyntaxException {
ListOfFullname uids = listoffullname.getFullname(listofuid);
return ResponseEntity.ok(uids);
}
public class FullnameRetrieverService {
public List<String> getFullname (List<String> listofuid) throws URISyntaxException {
URIBuilder builder = new URIBuilder("http://192.168.1.100:1106/idauthenticator/listoffullname");
String url = "http://192.168.1.100:1106/idauthenticator/listoffullname";
RestTemplate restTemplate = new RestTemplate();
// set headers
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
// create request body
HttpEntity<List<String>> entity = new HttpEntity<List<String>>(listofuid, headers);
System.out.println(entity.getBody());
ResponseEntity<ListOfFullname> test = restTemplate.exchange(builder.toString(), HttpMethod.GET, entity, ListOfFullname.class);
System.out.println(test.getBody().getFirstname());
return entity.getBody();
}}