I have a curl command:
curl -i -u guest:guest -H "content-type:application/json"
-XPUT \ http:
-d'{"format":"text","pattern":"#"}'
And I want to create an HTTP request in the Java API that will do the same. This curl command can be found in this README . It is used to start logging on RabbitMQ. The answer is not important.
At the moment, I created something like this (I deleted less important lines, for example, with catching exception, etc.), but, unfortunately, it does not work:
url = new URL("http://localhost:15672/api/traces/%2f/my-trace");
uc = url.openConnection();
uc.setRequestProperty("Content-Type", "application/json");
uc.setRequestProperty("format","json");
uc.setRequestProperty("pattern","#")
String userpass = "guest:guest";
String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes());
uc.setRequestProperty ("Authorization", basicAuth);
ENTIRE CODE
source
share