Java 幼儿园(20231104)RestTemplate调用外部接口

1、功能场景

        调用外部接口,简化与http服务的通信方式。

2、前置工作

        2.1、RestTemplate        直接使用依赖获取

<!--        RestTemplate-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.0.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.0.1.RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-json</artifactId>
            <version>2.0.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
            <version>1.5.8.RELEASE</version>
        </dependency>

        2.2、JSONObject        直接使用依赖获取

<!--        JSONObject-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.78</version>
        </dependency>

        2.3、RestTemplate 发送 GET请求(调用百度搜索引擎某接口)

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.springframework.http.*;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
import util.StringUtil;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

@Slf4j
public class RestTemplateTest {

    @Test
    public void restTemplateGetTest(){
        RestTemplate restTemplate = new RestTemplate();
        String trueUrl = "https://b.bdstatic.com/searchbox/image/gcp/20230706/1487205491.json?host={host}"; // 百度搜索引擎某接口
        Map trueParamMap = new HashMap<>();
        trueParamMap.put("host", "baijiahao.baidu.com");
        Object trueResult = restTemplate.getForObject(trueUrl, Object.class, trueParamMap);
        log.info("trueResult ==> "+StringUtil.nullToEmpty(trueResult));

        String errorUrl = "http://api.map.baidu.com/geoconv/v1/?coords={coords}&from={from}&to={to}&ak={ak}"; // 百度搜索引擎某接口
        Map errorParamMap = new HashMap<>();
        errorParamMap.put("coords", "114.21892734521,29.575429778924");
        errorParamMap.put("from", "1");
        errorParamMap.put("to", "5");
        errorParamMap.put("ak", "12231");
        Object falseResult = restTemplate.getForObject(errorUrl, Object.class, errorParamMap);
        log.info("falseResult ==> "+StringUtil.nullToEmpty(falseResult));
    }
    
    
}
trueResult ==> {v=5.7.1, fr=60, ip=0, op=93, w=72, h=72, nm=starer, ddd=0, assets=[{id=comp_0, layers=[{ddd=0, ind=1, ty=0, nm=scatter, refId=comp_1, sr=1, ks={o={a=0, k=100, ix=11}, r={a=0, k=-290.009, ix=10}, p={a=0, k=[48, 48, 0], ix=2}, a={a=0, k=[48, 48, 0], ix=1}, s={a=0, k=[100, 100, 100], ix=6}}, ao=0, w=96, h=96, ip=0, op=300, st=0, bm=0}, {ddd=0, ind=2, ty=0, nm=scatter, refId=comp_1, sr=1, ks={o={a=0, k=100, ix=11}, r={a=0, k=-156.917, ix=10}, p={a=0, k=[48, 48, 0], ix=2}, a={a=0, k=[48, 48, 0], ix=1}, s={a=0, k=[100, 100, 100], ix=6}}, ao=0, w=96, h=96, ip=0, op=300, st=0, bm=0}, {ddd=0, ind=3, ty=0, nm=scatter, refId=comp_1, sr=1, ks={o={a=0, k=100, ix=11}, r={a=0, k=-222.193, ix=10}, p={a=0, k=[48, 48, 0], ix=2}, a={a=0, k=[48, 48, 0], ix=1}, s={a=0, k=[100, 100, 100], ix=6}}, ao=0, w=96, h=96, ip=0, op=300, st=0, bm=0}, {ddd=0, ind=4, ty=0, nm=scatter, refId=comp_1, sr=1, ks={o={a=0, k=100, ix=11}, r={a=0, k=-90, ix=10}, p={a=0, k=[48, 48, 0], ix=2}, a={a=0, k=[48, 48, 0], ix=1}, s={a=0, k=[100, 100, 100], ix=6}}, ao=0, w=96, h=96, ip=0, op=300, st=0, bm=0}, {ddd=0, ind=5, ty=0, nm=scatter, refId=comp_1, sr=1, ks={o={a=0, k=100, ix=11}, r={a=0, k=0, ix=10}, p={a=0, k=[48, 48, 0], ix=2}, a={a=0, k=[48, 48, 0], ix=1}, s={a=0, k=[100, 100, 100], ix=6}}, ao=0, w=96, h=96, ip=0, op=300, st=0, bm=0}]}, {id=comp_1, layers=[{ddd=0, ind=1, ty=4, nm=形状图层 2, sr=1, ks={o={a=0, k=100, ix=11}, r={a=0, k=0, ix=10}, p={a=1, k=[{i={x=0.833, y=0.833}, o={x=0.167, y=0.167}, t=16, s=[48, 48, 0], to=[0.958, -0.979, 0], ti=[-2.438, 2.25, 0]}, {i={x=0.833, y=0.833}, o={x=0.167, y=0.167}, t=27, s=[53.75, 42.125, 0], to=[2.438, -2.25, 0], ti=[-1.756, 2.453, 0]}, {i={x=0.833, y=0.833}, o={x=0.167, y=0.167}, t=41, s=[62.625, 34.5, 0], to=[2.073, -2.896, 0], ti=[0.469, 2.229, 0]}, {t=61, s=[62.438, 26.25, 0]}], ix=2}, a={a=0, k=[0, 0, 0], ix=1}, s={a=0, k=[100, 100, 100], ix=6}}, ao=0, shapes=[{ty=gr, it=[{ind=0, ty=sh, ix=1, ks={a=0, k={i=[[0, 0], [0, 0]], o=[[0, 0], [0, 0]], v=[[7.062, -8.312], [16.069, -17.791]], c=false}, ix=2}, nm=路径 1, mn=ADBE Vector Shape - Group, hd=false}, {ty=tm, s={a=1, k=[{i={x=[0.667], y=[0.572]}, o={x=[0.333], y=[0]}, t=16, s=[0]}, {i={x=[0.667], y=[1]}, o={x=[0.333], y=[0.591]}, t=24, s=[72.352]}, {i={x=[0.833], y=[0.833]}, o={x=[0.167], y=[0.167]}, t=27, s=[92]}, {t=41, s=[98]}], ix=1}, e={a=1, k=[{i={x=[0.833], y=[0.833]}, o={x=[0.167], y=[0.167]}, t=9, s=[0]}, {i={x=[0.667], y=[1]}, o={x=[0.333], y=[0]}, t=16, s=[100]}, {t=27, s=[100]}], ix=2}, o={a=0, k=0, ix=3}, m=1, ix=2, nm=修剪路径 1, mn=ADBE Vector Filter - Trim, hd=false}, {ty=st, c={a=0, k=[1, 0.583812219956, 0.023529411765, 1], ix=3}, o={a=0, k=100, ix=4}, w={a=1, k=[{i={x=[0.833], y=[0.833]}, o={x=[0.167], y=[0.167]}, t=16, s=[4.5]}, {i={x=[0.833], y=[0.833]}, o={x=[0.167], y=[0.167]}, t=27, s=[6]}, {i={x=[0.833], y=[0.833]}, o={x=[0.167], y=[0.167]}, t=61, s=[2]}, {t=76, s=[0]}], ix=5}, lc=2, lj=1, ml=4, bm=0, nm=描边 1, mn=ADBE Vector Graphic - Stroke, hd=false}, {ty=tr, p={a=0, k=[0, 0], ix=2}, a={a=0, k=[0, 0], ix=1}, s={a=0, k=[100, 100], ix=3}, r={a=0, k=0, ix=6}, o={a=0, k=100, ix=7}, sk={a=0, k=0, ix=4}, sa={a=0, k=0, ix=5}, nm=变换}], nm=形状 1, np=4, cix=2, bm=0, ix=1, mn=ADBE Vector Group, hd=false}], ip=0, op=300, st=0, bm=0}]}, {id=comp_2, layers=[{ddd=0, ind=1, ty=4, nm=grad2, sr=1, ks={o={a=0, k=100, ix=11}, r={a=0, k=0, ix=10}, p={a=0, k=[31.623, 27.16, 0], ix=2}, a={a=0, k=[0, 0, 0], ix=1}, s={a=0, k=[176, 176, 100], ix=6}}, ao=0, shapes=[{ty=gr, it=[{ind=0, ty=sh, ix=1, ks={a=0, k={i=[[0, 0], [-0.558, -0.14], [0, 0], [-0.3, -0.332], [0.504, -0.562], [0.258, -0.88], [-0.292, -1.868], [0.685, -0.36], [1.616, 1.005], [1.472, -0.011], [0.475, -0.359], [-1.758, 3.905]], o=[[0, 0], [0.558, 0.14], [0, 0], [0.263, 0.292], [-1.439, 1.606], [-0.216, 0.803], [0.061, 0.388], [-0.736, 0.386], [-1.007, -0.627], [-0.712, 0.005], [1.629, -1.335], [1.728, -3.839]], v=[[-1.088, -8.239], [-0.05, -7.786], [4.508, -6.981], [5.443, -6.523], [5.175, -5.211], [1.442, -0.308], [1.98, 4.99], [1.696, 7.229], [-2.301, 5.788], [-5.643, 4.5], [-7.43, 4.973], [-1.62, -1.401]], c=true}, ix=2}, nm=路径 1, mn=ADBE Vector Shape - Group, hd=false}, {ty=gf, o={a=0, k=100, ix=10}, r=1, bm=0, g={p=7, k={a=0, k=[0, 1, 0.795, 0.36, 0.198, 1, 0.788, 0.337, 0.396, 1, 0.78, 0.314, 0.68, 1, 0.727, 0.169, 0.965, 1, 0.675, 0.024, 0.982, 1, 0.675, 0.024, 1, 1, 0.675, 0.024, 0, 0.557, 0, 0.778, 0, 1, 0.5, 1, 1, 1], ix=9}}, s={a=0, k=[-7.761, 4.463], ix=5}, e={a=0, k=[2.233, -3.885], ix=6}, t=1, nm=Gradient 2, mn=ADBE Vector Graphic - G-Fill, hd=false}, {ty=tr, p={a=0, k=[0, 0], ix=2}, a={a=0, k=[0, 0], ix=1}, s={a=0, k=[100, 100], ix=3}, r={a=0, k=0, ix=6}, o={a=0, k=100, ix=7}, sk={a=0, k=0, ix=4}, sa={a=0, k=0, ix=5}, nm=变换}], nm=矩形备份 2, np=2, cix=2, bm=0, ix=1, mn=ADBE Vector Group, hd=false}], ip=0, op=300, st=0, bm=0}, {ddd=0, ind=2, ty=4, nm=stary, sr=1, ks={o={a=0, k=100, ix=11}, r={a=0, k=0, ix=10}, p={a=0, k=[22.062, 20.35, 0], ix=2}, a={a=0, k=[0, 0, 0], ix=1}, s={a=0, k=[187, 187, 100], ix=6}}, ao=0, shapes=[{ty=gr, it=[{ind=0, ty=sh, ix=1, ks={a=0, k={i=[[0, 0], [0.418, -0.233], [0.568, 0.383], [-0.061, 0.469], [0, 0], [0.584, 0.602], [-0.177, 0.661], [-0.794, 0.13], [0, 0], [-0.316, 0.6], [-0.773, -0.012], [-0.252, -0.52], [0, 0], [-0.548, -0.095], [-0.199, -0.709], [0.453, -0.47], [0, 0], [-0.064, -0.325], [0.493, -0.361], [0.343, 0.182]], o=[[0, 0], [-0.418, 0.233], [-0.568, -0.383], [0.061, -0.469], [0, 0], [-0.584, -0.602], [0.177, -0.661], [0.794, -0.13], [0, 0], [0.316, -0.6], [0.773, 0.012], [0.252, 0.52], [0, 0], [0.548, 0.095], [0.199, 0.709], [-0.453, 0.47], [0, 0], [0.064, 0.325], [-0.493, 0.361], [-0.343, -0.182]], v=[[0, 7.517], [-4.277, 9.766], [-6.568, 10.206], [-6.837, 8.027], [-6, 3.157], [-9.601, -0.354], [-10.463, -2.308], [-8.189, -3.249], [-3.71, -3.903], [-1.733, -7.905], [0, -9.792], [1.733, -7.905], [3.71, -3.903], [8.451, -3.211], [10.412, -2.283], [9.385, -0.144], [6, 3.157], [6.796, 7.785], [6.752, 10.264], [4.287, 9.771]], c=true}, ix=2}, nm=路径 1, mn=ADBE Vector Shape - Group, hd=false}, {ty=rd, nm=圆角 1, r={a=0, k=1.4, ix=1}, ix=2, mn=ADBE Vector Filter - RC, hd=false}, {ty=fl, c={a=0, k=[1, 0.674509823322, 0.023529412225, 1], ix=4}, o={a=0, k=100, ix=5}, r=1, bm=0, nm=填充 1, mn=ADBE Vector Graphic - Fill, hd=false}, {ty=tr, p={a=0, k=[0, 0], ix=2}, a={a=0, k=[0, 0], ix=1}, s={a=0, k=[100, 100], ix=3}, r={a=0, k=0, ix=6}, o={a=0, k=100, ix=7}, sk={a=0, k=0, ix=4}, sa={a=0, k=0, ix=5}, nm=变换}], nm=蒙版, np=3, cix=2, bm=0, ix=1, mn=ADBE Vector Group, hd=false}], ip=0, op=300, st=0, bm=0}]}], layers=[{ddd=0, ind=5, ty=0, nm=scattered, refId=comp_0, sr=1, ks={o={a=0, k=100, ix=11}, r={a=0, k=0, ix=10}, p={a=0, k=[36, 36, 0], ix=2}, a={a=0, k=[48, 48, 0], ix=1}, s={a=0, k=[68.229, 68.229, 100], ix=6}}, ao=0, w=96, h=96, ip=5, op=305, st=5, bm=0}, {ddd=0, ind=6, ty=4, nm=cream1, sr=1, ks={o={a=0, k=100, ix=11}, r={a=0, k=0, ix=10}, p={a=0, k=[36, 36, 0], ix=2}, a={a=0, k=[0, 0, 0], ix=1}, s={a=0, k=[100, 100, 100], ix=6}}, ao=0, shapes=[], ip=5, op=305, st=5, bm=0}, {ddd=0, ind=7, ty=0, nm=star2, refId=comp_2, sr=1, ks={o={a=1, k=[{i={x=[0.833], y=[0.833]}, o={x=[0.167], y=[0.167]}, t=22, s=[0]}, {i={x=[0.833], y=[0.833]}, o={x=[0.167], y=[0.167]}, t=24, s=[25]}, {i={x=[0.833], y=[0.833]}, o={x=[0.167], y=[0.167]}, t=38, s=[100]}, {t=123, s=[100]}], ix=11}, r={a=0, k=0, ix=10}, p={a=0, k=[35.938, 35.928, 0], ix=2}, a={a=0, k=[22, 22.75, 0], ix=1}, s={a=1, k=[{i={x=[0.591, 0.591, 0.591], y=[-1.984, -1.984, 14.842]}, o={x=[0.167, 0.167, 0.167], y=[0.167, 0.167, -16.667]}, t=5, s=[-35, -35, 100]}, {i={x=[0.69, 0.69, 0.69], y=[1, 1, 1]}, o={x=[0.254, 0.254, 0.254], y=[0.431, 0.431, -7.251]}, t=24, s=[0, 0, 100]}, {i={x=[0.667, 0.667, 0.667], y=[1, 1, 1]}, o={x=[0.167, 0.167, 0.167], y=[0.167, 0.167, -0.222]}, t=40, s=[127, 127, 100]}, {i={x=[0.667, 0.667, 0.667], y=[1, 1, 1]}, o={x=[0.167, 0.167, 0.167], y=[0.167, 0.167, 0.192]}, t=58, s=[92.586, 92.586, 100]}, {i={x=[0.667, 0.667, 0.667], y=[1, 1, 1]}, o={x=[0.167, 0.167, 0.167], y=[0.167, 0.167, 0.16]}, t=72, s=[103, 103, 100]}, {i={x=[0.833, 0.833, 0.833], y=[0.833, 0.833, 0.833]}, o={x=[0.167, 0.167, 0.167], y=[0.167, 0.167, 0.167]}, t=79, s=[100, 100, 100]}, {t=123, s=[100, 100, 100]}], ix=6}}, ao=0, w=44, h=44, ip=5, op=305, st=5, bm=0}, {ddd=0, ind=8, ty=4, nm=star1, sr=1, ks={o={a=1, k=[{i={x=[0.667], y=[1]}, o={x=[0.167], y=[0.167]}, t=4, s=[100]}, {t=12, s=[0]}], ix=11}, r={a=0, k=0, ix=10}, p={a=0, k=[36.25, 33.774, 0], ix=2}, a={a=0, k=[0, 0, 0], ix=1}, s={a=1, k=[{i={x=[0.667, 0.667, 0.667], y=[1, 1, 1]}, o={x=[0.167, 0.167, 0.167], y=[0.167, 0.167, 0]}, t=4, s=[189.762, 189.762, 100]}, {t=12, s=[31.762, 31.762, 100]}], ix=6}}, ao=0, shapes=[{ty=gr, it=[{ind=0, ty=sh, ix=1, ks={a=0, k={i=[[0, 0], [0.213, -0.105], [0.384, 0.314], [-0.036, 0.273], [0, 0], [0.16, 0.15], [-0.2, 0.556], [-0.254, 0.033], [0, 0], [-0.133, 0.281], [-0.729, -0.006], [-0.12, -0.256], [0, 0], [-0.315, -0.051], [-0.177, -0.532], [0.201, -0.215], [0, 0], [-0.053, -0.321], [0.403, -0.291], [0.408, 0.207]], o=[[0, 0], [-0.213, 0.105], [-0.384, -0.314], [0.036, -0.273], [0, 0], [-0.16, -0.15], [0.2, -0.556], [0.254, -0.033], [0, 0], [0.133, -0.281], [0.729, 0.006], [0.12, 0.256], [0, 0], [0.315, 0.051], [0.177, 0.532], [-0.201, 0.215], [0, 0], [0.053, 0.321], [-0.403, 0.291], [-0.408, -0.207]], v=[[0, 6.615], [-4.503, 8.964], [-5.831, 8.987], [-6.103, 7.775], [-5.242, 2.82], [-8.873, -0.757], [-9.273, -2.022], [-8.12, -2.705], [-3.294, -3.405], [-1.356, -7.286], [-0.042, -8.452], [1.271, -7.391], [3.228, -3.372], [8.166, -2.685], [9.288, -1.991], [8.867, -0.73], [5.308, 2.82], [6.102, 7.629], [5.831, 8.963], [4.389, 8.909]], c=true}, ix=2}, nm=路径 1, mn=ADBE Vector Shape - Group, hd=false}, {ty=rd, nm=圆角 1, r={a=0, k=1.4, ix=1}, ix=2, mn=ADBE Vector Filter - RC, hd=false}, {ty=st, c={a=0, k=[0.20000000298, 0.20000000298, 0.20000000298, 1], ix=3}, o={a=0, k=100, ix=4}, w={a=0, k=1.6, ix=5}, lc=3, lj=2, bm=0, nm=描边 1, mn=ADBE Vector Graphic - Stroke, hd=false}, {ty=tr, p={a=0, k=[0, 0], ix=2}, a={a=0, k=[0, 0], ix=1}, s={a=0, k=[103, 103], ix=3}, r={a=0, k=0, ix=6}, o={a=0, k=100, ix=7}, sk={a=0, k=0, ix=4}, sa={a=0, k=0, ix=5}, nm=变换}], nm=星形, np=3, cix=2, bm=0, ix=1, mn=ADBE Vector Group, hd=false}], ip=0, op=300, st=0, bm=0}, {ddd=0, ind=9, ty=4, nm=gard, parent=8, sr=1, ks={o={a=1, k=[{i={x=[0.667], y=[1]}, o={x=[0.167], y=[0.167]}, t=4, s=[100]}, {t=12, s=[0]}], ix=11}, r={a=0, k=0, ix=10}, p={a=0, k=[2.815, 2.375, 0], ix=2}, a={a=0, k=[0, 0, 0], ix=1}, s={a=0, k=[98.808, 98.808, 100], ix=6}}, ao=0, shapes=[{ty=gr, it=[{ind=0, ty=sh, ix=1, ks={a=0, k={i=[[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [1.689, 0.69], [0, 0], [-1.786, 3.521]], o=[[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [-1.689, -0.69], [0, 0], [1.789, -3.527]], v=[[0.903, -6.386], [2.22, -5.633], [6.899, -4.563], [2.583, 0.284], [3.343, 6.95], [-1.062, 5.316], [-5.704, 5.407], [0.143, 0.004]], c=true}, ix=2}, nm=路径 1, mn=ADBE Vector Shape - Group, hd=false}, {ty=gf, o={a=0, k=100, ix=10}, r=1, bm=0, g={p=3, k={a=0, k=[0, 0.784, 0.796, 0.824, 0.5, 0.892, 0.898, 0.912, 1, 1, 1, 1], ix=9}}, s={a=0, k=[-6.037, 3.328], ix=5}, e={a=0, k=[6.037, -5.434], ix=6}, t=1, nm=gradient 1, mn=ADBE Vector Graphic - G-Fill, hd=false}, {ty=tr, p={a=0, k=[0.019, 0.04], ix=2}, a={a=0, k=[0, 0], ix=1}, s={a=0, k=[100, 100], ix=3}, r={a=0, k=0, ix=6}, o={a=0, k=100, ix=7}, sk={a=0, k=0, ix=4}, sa={a=0, k=0, ix=5}, nm=变换}], nm=矩形备份 2, np=2, cix=2, bm=0, ix=1, mn=ADBE Vector Group, hd=false}], ip=0, op=300, st=0, bm=0}], markers=[]}
falseResult ==> {status=200, message=APP不存在,AK有误请检查再重试}

        2.4、RestTemplate 发送 POST请求(调用百度搜索引擎某接口)

public void restTemplatePostTest(){
        // 设置请求报文首部信息
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
        headers.setConnection("Keep-Alive");
        // 设置请求报文正文信息(请求参数)
        Map<String, Object> map = new HashMap<>();
        map.put("_","1699083851535");
        map.put("refer","https://baijiahao.baidu.com/s?id=1781518896354106359&wfr=spider&for=pc");
        map.put("ak","1e3f2dd1c81f2075171a547893391274");
        map.put("ver","1");
        // 设置 restTemplate 信息
        RestTemplate restTemplate = new RestTemplate();
        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
        requestFactory.setConnectTimeout(30000); // 连接超时时间
        restTemplate.setRequestFactory(requestFactory);
        HttpEntity requestEntity = new HttpEntity(map, headers);
        String url = "https://passport.baidu.com/cap/init";
        try { 
            ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, requestEntity, String.class);
            log.info("responseEntity ==> "+StringUtil.nullToEmpty(responseEntity));
            HttpStatus httpStatus = responseEntity.getStatusCode();
            log.info("httpStatus ==> "+StringUtil.nullToEmpty(httpStatus));
            int statusCode = responseEntity.getStatusCodeValue();
            log.info("statusCode ==> "+StringUtil.nullToEmpty(statusCode));
            HttpHeaders responseHeaders = responseEntity.getHeaders();
            log.info("responseHeaders ==> "+StringUtil.nullToEmpty(headers));
            String responseBody = responseEntity.getBody();
            JSONObject bodyObject = JSONObject.parseObject(responseBody);
            log.info("bodyObject ==> "+StringUtil.nullToEmpty(bodyObject));
        } catch (Exception e) {
            log.error("连接超时,调用百度接口失败", e);
        }
    }
18:04:31.317 [main] INFO ForTest.RestTemplateTest - responseEntity ==> <200,{"code":100600,"msg":"Unauthorized User"},{Access-Control-Allow-Credentials=[true], Access-Control-Allow-Methods=[POST], Access-Control-Allow-Origin=[://], Content-Length=[41], Content-Type=[application/json; charset=utf-8], Date=[Sat, 11 Nov 2023 10:04:31 GMT], Strict-Transport-Security=[max-age=31536000]}>
18:04:31.317 [main] INFO ForTest.RestTemplateTest - httpStatus ==> 200
18:04:31.317 [main] INFO ForTest.RestTemplateTest - statusCode ==> 200
18:04:31.317 [main] INFO ForTest.RestTemplateTest - responseHeaders ==> {Content-Type=[application/json], Accept=[application/json], Connection=[Keep-Alive]}
18:04:31.397 [main] INFO ForTest.RestTemplateTest - bodyObject ==> {"msg":"Unauthorized User","code":100600}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值