gpt4 book ai didi

android - setRequestProperty 抛出 java.lang.IllegalStateException : Cannot set request property after connection is made

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:16:21 31 4
gpt4 key购买 nike

我收到 java.lang.IllegalStateException:

java.lang.IllegalStateException: Cannot set request property after connection is made error when setRequestProperty 方法被调用后url.openConnection();

这是我正在尝试的:

URL url = new URL("https://49.205.102.182:7070/obsplatform/api/v1/mediadevices/545b801ce37e69cc");
urlConnection = (HttpsURLConnection) url
.openConnection();
urlConnection.setRequestProperty("Content-Type","application/json");

有什么建议吗?提前致谢。

最佳答案

如果您在调试观察器调用中通常会发生这种情况,例如 conn.getResponseCode() 或在请求实际发出或完成之前查询请求结果的任何内容。这导致,在调试期间,观察者在正确设置您的请求之前执行请求,然后它变得无效。

关于android - setRequestProperty 抛出 java.lang.IllegalStateException : Cannot set request property after connection is made,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22320418/

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