convert curl call into java urlconnection call
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have curl command: curl -i -u guest:guest -H "content-type:application/json" -XPUT \ http://localhost:15672/api/traces/%2f/my-trace \ -d'{"format":"text","pattern":"#"}' And I want to create HTTP Request in Java API which will do the same thing. This curl command can be found in this README . It is used to start recording log on RabbitMQ. Response is not important. For now I created something like this (I've deleted less important lines i.e. with catching exception etc.), but unfortunately it doesn't work: url = new URL("http://localhost