Hard to say without knowing what you are doing :)

Using ObjectRepresentation for a String is strange if that is your usecase as it is meant for a serializable Java object. If you are just wanting to pass plain text then you should use the following:

if (variant.getMediaType().equals(MediaType.TEXT_PLAIN)) {
          result = new StringRepresentation("Testing....");
      }


Stanczak Group wrote:
Should I even be using object?

Stanczak Group wrote:
So how do I use 1.0 to get objects?

Jonathan Hall wrote:
Ah, I am running from http://www.restlet.org/downloads/archives/1.1/

Jerome wrote:
"Now that the 1.0 code base seems to be quite stable it is time to move forward. We have just created a maintenance branch for 1.0 in SVN. From now on, the SVN trunk will be dedicated to the upcoming version 1.1."

Bleeding edge and all that :0)

Stanczak Group wrote:
I don't have a request.setClientInfo() in my request object. Do I have an older version? I'm using 1.0.4.

Jonathan Hall wrote:
Whoops,

clientInfo.setAcceptedMediaTypes(new ArrayList<Preference<MediaType>>().);

should be:

clientInfo.setAcceptedMediaTypes(new ArrayList<Preference<MediaType>>());
Jonathan Hall wrote:
Hi,
try something like:

ClientInfo clientInfo = new ClientInfo();
clientInfo.setAcceptedMediaTypes(new ArrayList<Preference<MediaType>>().); clientInfo.getAcceptedMediaTypes().add(new Preference<MediaType>(MediaType.APPLICATION_JAVA_OBJECT));
request.setClientInfo(clientInfo);

jon

Stanczak Group wrote:
Here's the code:

Request request = new Request(Method.GET, "http://localhost:8182/users/dog";); ChallengeResponse authentication = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, "admin", "admin");
       request.setChallengeResponse(authentication);
       Client client = new Client(Protocol.HTTP);
       Response response = client.handle(request);
       String str = (String) response.getEntityAsObject();
       System.out.println(str);

Keeps requesting MediaType.TEXT_PLAIN but I'm trying to get an object. I have the server setup to send object.


if (variant.getMediaType().equals(MediaType.APPLICATION_JAVA_OBJECT)) {
           result = new ObjectRepresentation("Testing....");
           System.out.println("\nAPPLICATION_JAVA_OBJECT\n");
       }

Where am I going wrong?









Reply via email to