title: Eclipse Kura http authentication failed
body: <p>I am trying to do a simple HTTP Get and POST request in java to my Eclipse Kura gateway but i dont know how to authenticate using username and password. I tried using the url syntax <a href="http://user:pw@ipaddress:port/" rel="nofollow noreferrer">http://user:pw@ipaddress:port/</a> but i still get HTTP error code 401.</p>
  
  <pre><code>import java.io.*;
  import java.net.*;
  
  public class HTTP {
  
  public static String getHTML() throws Exception {
      StringBuilder result = new StringBuilder();
  
      String urlToRead = "http://user:pw@ipaddress:port";
  
      URL url = new URL(urlToRead);
  
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setRequestMethod("GET");
  
      BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
      String line;
      while ((line = rd.readLine()) != null) {
          result.append(line);
      }
      rd.close();
      return result.toString();
  }
  
  public static void main(String[] args) throws Exception {
      System.out.println(getHTML());
  }
  }
  </code></pre>