javagoogle-cloud-platformgoogle-app-enginegoogle-cloud-endpoints

appengine sees User as additional parameter


I am using OAuth with my app-engine server. It's rather simple to do, simple add User as one of the parameters. But when I do I get the compile error

Multiple entity parameters. there can only be a single entity parameter per method...

@ApiMethod(path = "updateDocument", name = "updateDocument", httpMethod = ApiMethod.HttpMethod.POST)
public void updateDocument(User user, MyDocument input){
  ...
}

It works fine for the methods of the form

public MyBean sayHiUser(@Named("name") String name, User user)

It just doesn't work when I have custom objects like MyDocument.


Solution

  • I have the feeling your User is not of type import com.google.appengine.api.users.User.

    The documentation states that "there can only be a single entity parameter per method" (see https://cloud.google.com/appengine/docs/java/endpoints/parameter-and-return-types).

    However "Any type except a parameter or injected type is considered an entity type" and com.google.appengine.api.users.User is of type "injected": so you should not have any problem normally, unless your User is not of this type.

    Personaly I have methods like

    public Customer insert(final User user, Customer customer, ...
    

    which work perfectly well