Showing posts with label headres. Show all posts
Showing posts with label headres. Show all posts

Monday, 25 November 2019

Generic function for Post Data with some headers in spring

 public <T,K> K postApiCall(T t, HttpHeaders headers, String url, Class<K> resposne){
        try {
            RestTemplate restTemplate = new RestTemplate();
            headers.add("Content-Type","application/json");
            HttpEntity<T> entity = new HttpEntity<T>(t, headers);
            ResponseEntity<K> result = restTemplate.exchange(url, HttpMethod.POST, entity, resposne);
            System.out.println(result.getBody());
            return result.getBody();
        }catch (Exception ee){
            ee.printStackTrace();
        }
        return null;
    }

links for Data Structure

  1) 𝐁𝐞𝐜𝐨𝐦𝐞 𝐌𝐚𝐬𝐭𝐞𝐫 𝐢𝐧 𝐋𝐢𝐧𝐤𝐞𝐝 𝐋𝐢𝐬𝐭:  https://lnkd.in/gXQux4zj 2) 𝐀𝐥𝐥 𝐭𝐲𝐩𝐞𝐬 𝐨𝐟 𝐓𝐫𝐞𝐞 𝐓𝐫𝐚𝐯𝐞𝐫𝐬𝐚𝐥𝐬...