调用setRequestProperty抛出java.lang.IllegalStateException:不能设置请求属性连接后 [英] setRequestProperty throwing java.lang.IllegalStateException: Cannot set request property after connection is made
本文介绍了调用setRequestProperty抛出java.lang.IllegalStateException:不能设置请求属性连接后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到 java.lang.IllegalStateException
:
java.lang.IllegalStateException
:不能设置请求属性建立连接错误之后,当调用setRequestProperty
方法被称为后 url.openConnection();
java.lang.IllegalStateException
: Cannot set request property after connection is made error when setRequestProperty
method is called after
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");
有什么建议吗?先谢谢了。
any suggestions please? Thanks in advance.
推荐答案
我只是有这个问题,
没有调试(可以打印日志)应当一切正常运行。
I only have this issue while in debugging mode, Run without debugging (You can print logs) everything should work fine
这篇关于调用setRequestProperty抛出java.lang.IllegalStateException:不能设置请求属性连接后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文