Bashiro,
According to their spec, you should probably be using something similar
to (keep in mind that I don't have an account with no-ip):
import java.net.URLEncoder;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;
/**
* NoIpTest
*
* javac NoIpTest.java
* java NoIpTest myhostname 1.2.3.4
*
* or take modify the source accordingly....
*/
public class NoIpTest {
static final String enc = "UTF-8";
static final String username = "myusername";
static final String password = "mypassword";
static final String BASE_URI =
"https://dynupdate.no-ip.com/nic/update";
static String hostname = "mytest.testdomain.com";
static String IP = "1.2.3.4";
public static void main(String[] args) {
// if arg 1 is hostname and arg 2 is ip
if ( args.length == 2 ) {
hostname = args[0];
IP = args[1];
}
HttpClient client = new HttpClient();
GetMethod get = new GetMethod(getRequestURI());
client.getState().setCredentials(
new AuthScope("dynupdate.no-ip.com",
443, "realm"),
new
UsernamePasswordCredentials(username, password));
get.setDoAuthentication(true);
try {
// execute method and possibly handle any error
responses
int status = client.executeMethod(get);
System.out.println("HTTP Status: " + status);
// Get and print the result
String result = get.getResponseBodyAsString();
System.out.println(result);
} catch (Exception e) {
// Catch any exceptions and print the stack
trace
e.printStackTrace();
} finally {
// Release the connection
get.releaseConnection();
}
}
private static String getRequestURI() {
return BASE_URI + "?" + "hostname=" +
URLEncoder.encode(hostname, enc)
+ "&myip=" + URLEncoder.encode(IP, enc);
}
}
On Tue, 2008-02-05 at 15:25 -0500, Bashiro wrote:
>
>
> Thanks for the reply.
> I have already tried yur suggestion before sending the
> mail to this forum (but did not work).
> Here is the link to the site's specification I am trying to
> connect to:
> http://www.no-ip.com/integrate/request
>
> check it your self and see what might be wrong there....
> Bashiro
> Drammen-Norway
>
> --- On Tue 02/05, Joshua Preston < [EMAIL PROTECTED] > wrote:
> From: Joshua Preston [mailto: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Cc: [email protected]
> Date: Tue, 05 Feb 2008 14:36:13 -0500
> Subject: Re: GET PROBLEMS!
>
> Bashiro,Please see:
> http://hc.apache.org/httpclient-3.x/methods/get.htmlBasically, you aren't
> using a valid URI,
> seehttp://en.wikipedia.org/wiki/Uniform_Resource_Identifier, as you'remissing
> the protocol and hostname...>From the Javadocs,GetMethod(String uri)
> Constructor specifying a URI.Format it like,GetMethod get =
> newGetMethod("http://myhost.mydomain.local/nic/update?hostname=mytest.testdomain.com&myip=1.2.3.4");Thanks!On
> Tue, 2008-02-05 at 14:28 -0500, Bashiro wrote:> Hello folks,> > I first
> connect to a site and then make a GET request.> > after authentication the
> site has a GET request code as;> >
> /nic/update?hostname=mytest.testdomain.com&myip=1.2.3.4 HTTP/1.0> > when I
> put> GetMethod get = new
> GetMethod("/nic/update?hostname=mytest.testdomain.com&myip=1.2.3.4");> > I
> get the following erros;> host parameter is null;> > > where am I going wrong
> ? or why is httpclient not able to handle this ?> > Thanks for any help> >
> bashiro> >
> _______________________________________________> No banners. No pop-ups. No
> kidding.> Make My Way your home on the Web - http://www.myway.com> > > >
> ---------------------------------------------------------------------> To
> unsubscribe, e-mail: [EMAIL PROTECTED]> For additional commands, e-mail:
> [EMAIL PROTECTED]>
>
> _______________________________________________
> No banners. No pop-ups. No kidding.
> Make My Way your home on the Web - http://www.myway.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>