1

Days ago I try to make an application similar to No-IP DUC (Dynamic DNS Update Clients) in java but I have presented a problem and not how to fix ... Now I can retrieve the domains I have registered with the following line of code:

URLConnection conexion = new URL( "http://dynupdate.no-ip.com/list-hosts.php?email="+USER+"&pass="+PASSWORD ).openConnection();

but when I update with the following URL you recommend on page http://www.no-ip.com/integrate/request, I get an exception ...

URLConnection conexion = new URL( "http://"+USER+":"+PASSWORD+"@dynupdate.no-ip.com/nic/update?hostname="+DOMAIN+"&myip="+IP ).openConnection();

The strange thing is that manually copy the URL in the address, the update is done without problem ... If anyone can help me I appreciate it a lot ...

Tom
  • 39,851
  • 25
  • 129
  • 164
ju4n
  • 11
  • 3
  • Why did you put the title in Portuguese or Spanish? – CRM May 27 '12 at 02:08
  • user/pass in the URL string does not work for authentication in `URLConnection`. You need to explicitly enable **Basic Authentication**. See here: http://stackoverflow.com/questions/496651/connecting-to-remote-url-which-requires-authentication-using-java – Sandman4 May 27 '12 at 19:53
  • thank you very much for the cooperation ... but I still doubt the link ... that is, I do these steps: http://www.javaworld.com/javatips/jw-javatip47.html but to create the url is giving me an exception MalformedURLException: For input string: "PASSWORD@dynupdate.no-ip.com" and no use linking to create the url and ask me username and password and so do the setRequestProperty ("Authorization", "Basic" + encoding); – ju4n May 29 '12 at 20:38

1 Answers1

1

Well I faced this situation as well. Found out the reason for this error is that we are using an email address for the username. The "@" present inside it conflicts with the resulting url. Try to use URLEncode to encode the username and the password part.

String username = URLEncoder.encode("abc@xyz.com", "UTF-8");
String password = URLEncoder.encode("password", "UTF-8");
URL url = new URL( "http://"+username+":"+password+"@dynupdate.no-ip.com/nic/update?hostname="+hostname+"&myip="+ip);           
URLConnection urlConnection = url.openConnection();
Konoha
  • 307
  • 1
  • 4
  • 12