I think you must specify the representation type you wish to accept in your
Client.

When you use a web browser to test, the Accept: header field already
contains MIME types that a browser would want to receive, so that would
explain why it works when you view it in a browser.  If you have a tool like
TCPMon that you can use to inspect your network traffic, it would help you
to see how the accept types differ when you use a browser and when you use
your Client library.

You might find this thread helpful:
http://osdir.com/ml/java.restlet/2007-04/msg00002.html

On Tue, Sep 16, 2008 at 4:32 PM, Kevin <[EMAIL PROTECTED]> wrote:

> hello. Im having a problem with the client.
> Im following the tutorial
> http://www.restlet.org/documentation/1.0/tutorial
>
> /////////////////////////////////////////////////////////////////////////////////
> // Prepare the request
> Request request = new Request(Method.GET, "http://localhost:8182/myuri";);
> // Ask to the HTTP client connector to handle the call
> Client client = new Client(Protocol.HTTP);
> Response response = client.handle(request);
> if (response.getStatus().isSuccess()) {
>    // Output the response entity on the JVM console
>    response.getEntity().write(System.out);
>
> } else if (response.getStatus()
>        .equals(Status.CLIENT_ERROR_UNAUTHORIZED)) {
>    // Unauthorized access
>    System.out
>            .println("Access authorized by the server, " +
>                    "check your credentials");
> } else {
>    // Unexpected status
>    System.out.println("An unexpected status was returned: "
>            + response.getStatus());
> }
>
> ////////////////////////////////////////////////////////////////////////////
>
> The problem is that response.getStatus().isSuccess() is true, but
> response.getEntity() is always returning null.
> and it should not be because if i do a get on http://localhost:8182/myuriwith
> my web browser it returns content.
>
> any ideas?
>
>

Reply via email to