Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8459837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:26:20+00:00 2026-06-10T13:26:20+00:00

So I am new with restlet. I am creating a Android application that can

  • 0

So I am new with restlet. I am creating a Android application that can communicate with a GAE server (with objectify DB)
I Did this very good tutorial to learn:
http://www.tutos-android.com/webservice-rest-android-appengine-restlet-objectify

It’s working very well but do very little.
Onely 2 methods:

public interface UserControllerInterface {
@Put
void create(User user);
@Get
Container getAllUsers();
}

For my application its more complicated so I add many more methods:

public interface UserControllerInterface {
@Put
public void createUser(ObagooUser user);

@Put
public void createMessage(ObagooUser user, String message);

@Put
public void updateMessage(ObagooMessage message);

@Get
public List<ObagooUser> getAllUser();

@Get
public ObagooUser getUserById(String id);

@Get
public List<ObagooMessage> getAllMessage();

@Get
public List<ObagooMessage> getAllMessageFromSender(ObagooUser sender);

@Get
public ObagooMessage getFreeMessage(ObagooUser user);
}

Each of these mothds working server side (I tested with Junit).

Now I am coding the android part and I am having problems.
When I do a simple call to getAllMessage() I get an error:

java.lang.IllegalArgumentException: id cannot be zero
at com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:44)
at     com.googlecode.objectify.ObjectifyFactory.typedKeyToRawKey(ObjectifyFactory.java:269)
at com.googlecode.objectify.impl.ObjectifyImpl.find(ObjectifyImpl.java:159)
at com.googlecode.objectify.impl.ObjectifyImpl.find(ObjectifyImpl.java:183)
at com.obagoo.dao.ObagooUserDAO.getUserById(ObagooUserDAO.java:43)
at com.obagoo.controller.ObagooController.getUserById(ObagooController.java:47)

It’s going in the wrong method (getUserById).

I put a break point in my getAllMessage and it’s going in, but it is also going in other methods.

If I test many times, sometimes it’s calling, createUser or another random method.

Do you see what I am doind wrong?

Adding the getAllMessage code:

public List<ObagooMessage> getAllMessage() {
    // logger.debug("Getting all Obagoo Messages");

    List<ObagooMessage> msg = new ArrayList<ObagooMessage>();
    Objectify ofy = ObjectifyService.begin();

    Query<ObagooMessage> q = ofy.query(ObagooMessage.class);

    for (ObagooMessage u : q) {
        msg.add(u);
    }

    return msg;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:26:22+00:00Added an answer on June 10, 2026 at 1:26 pm

    In the examples that I’ve seen, its always shown that you should separate the controller/resource handling the URI for the list resource from the single item (id/name based) resource. So you would have something like:

    router.attach("/users", UsersController.class);
    router.attach("/users/{id}", UserController.class
    router.attach("/messages", MessagesController.class);
    

    Notice the plural naming on the first class: UsersController, and singular naming on the the second class: UserController. The first class would handle cases where no id was being provided, such as a get of all users. Also, note when the id is provided in the URI, it can be automatically mapped into an id field on the class. So the Get method has no parameters on the method call.

    As for handling a subset, then for messages from a specific user, that could be handled with query parameters. For instance when calling via a URI with /messages?sender=id, the MessagesController.class would use the following in the method handling the Get:

    Form queryParams = getRequest().getResourceRef().getQueryAsForm(); 
    String id = queryParams.getFirstValue("sender"); 
    

    Hope that helps. I’m no expert, so anyone feel free to correct me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developping an Android Application, comunicating with a GAE server + Objectify DB.
I have this Restlet structure: I instanciate a Server object: server = new Server(new
We're planning a new API server that will mainly serve JSON responses, with a
How I can add Header params in restlet android? I have following code: ClientResource
I am using restlet server has a RESTful provider for my mobile application. Is
Where can I embed startup initialization code in a Restlet web application, without using
I Followed this tutorial for my Restlet server in the Google App Engine: http://wiki.restlet.org/docs_2.0/13-restlet/21-restlet/318-restlet/303-restlet.html
I am creating an API (Restlet, GAE) and implemented OpenId for authentication and OAuth2
New to linux and c++. I wante to create an application that only needs
I'm testing an application that starts a restlet, when an http request arrive to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.