gpt4 book ai didi

java - HttpURLConnection RequestPropertys 为空

转载 作者:可可西里 更新时间:2023-11-01 16:41:57 26 4
gpt4 key购买 nike

我正在尝试将我的 Java 应用程序连接到位于 https://api.guildwars2.com/v2/ 的公共(public)游戏 API

为此我写了下面的代码:

url = new URL(URL_PREFIX + "account");

HttpURLConnection con = (HttpURLConnection) url.openConnection();

String authent = "Bearer ".concat(API_KEY);

//Authorization
con.setRequestProperty("Authorization", authent);
con.addRequestProperty("Authorization", authent);
System.out.println(con.getRequestProperty("Authorization")); //null
con.setDoOutput(true);
con.setRequestMethod("GET");

我收到 http 400 错误,我认为这是因为未设置授权属性。为什么我得到的 getRequestProperty 为空?

最佳答案

我在 guildwars 论坛上发现一个帖子说他们有内部问题,
Review that :).

劳顿·坎贝尔
网络程序员

I posted a note in our internal chat about it being broken, but yeah, it’s the weekend so it’s probably not gonna be fixed before Monday. Really sorry about that

关于java - HttpURLConnection RequestPropertys 为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31383218/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com