日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

RestTemplate的post使用,token調用

作者:自由_free 更新時間: 2022-05-11 編程語言

RestTemplate的post使用

        MokaJobVM mokaJobVM = restTemplate.postForObject(url, entity, MokaJobVM.class);

url為路徑,entity為請求體,包括請求頭,第三個參數為響應參數

String apiKey = “gdfgfdgfdgdfgdf”;

    HttpHeaders headers = new HttpHeaders();
    headers.set("authorization", "Basic " + Base64.getEncoder().encodeToString(apiKey.getBytes()));


    MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
    headers.setContentType(type);

    HttpEntity entity = new HttpEntity(JacksonUtil.to(params), headers);

調用posy接口一定要在請求頭設置Type

exchange的調用方式
ResponseEntity exchange = restTemplate.exchange(url, HttpMethod.POST, entity, MokaJobVM.class);

原文鏈接:https://blog.csdn.net/weixin_49194846/article/details/120038207

欄目分類
最近更新