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

學(xué)無先后,達(dá)者為師

網(wǎng)站首頁 編程語言 正文

RestTemplate的post使用,token調(diào)用

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

RestTemplate的post使用

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

url為路徑,entity為請求體,包括請求頭,第三個參數(shù)為響應(yīng)參數(shù)

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);

調(diào)用posy接口一定要在請求頭設(shè)置Type

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

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

欄目分類
最近更新