Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.net.URL;
- import java.net.URLConnection;
- import javax.xml.bind.DatatypeConverter;
- import java.io.IOException;
- import java.net.MalformedURLException;
- public class Temp{
- public static void main(String[] args){
- URL url = null;
- try {
- url = new URL("http://localhost:15672/api/traces/%2f/my-trace");
- } catch (MalformedURLException e) {
- System.out.println("MalformedUrlException: " + e.getMessage());
- e.printStackTrace();
- }
- URLConnection uc = null;
- try {
- uc = url.openConnection();
- uc.setRequestProperty("Content-Type", "application/json");
- uc.setRequestProperty("format","json");
- uc.setRequestProperty("pattern","#");
- } catch (IOException e) {
- System.out.println("IOException: " + e.getMessage());
- e.printStackTrace();
- }
- String userpass = "guest" + ":" + "guest";
- String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes());
- uc.setRequestProperty ("Authorization", basicAuth);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement