发送请求:
private void executeHttpGet(String url) throws IOException {
HttpURLConnection connection;
connection = (HttpURLConnection) (new URL(url).openConnection());
connection.setRequestProperty("Authorization","Bearer" + "<my_token>");
connection.connect();
connection.getContent();
System.out.println(connection.getRequestMethod());
}
但是请求失败并出现 401 错误 - 没有授权。但是通过一个同理的邮递员,答案来了。(get请求默认附上)
忘记标题中的空格