Endpoint Collection Option

Im using the endpoints of the Google App Engine Cloud, and I'm trying to get the collection parameter. Not sure if I can do this. I know that I can return a list or any collection.

It:

   public List<Pair> initializationSetup(Pair pPair){}

It works fine, but if I try to get a list of pairs, the .api file is not created.

   public List<Pair> initializationSetup(List<Pair> pPairs){

thank

+5
source share
2 answers

Cloud endpoints apply only to classes that have a bean standard.

So, I created a new ObjectListContainer class:

public class ObjectListContainer {
    public List<Object> getObjectsList() {
        return ObjectsList;
    }
    public void setObjectsList(List<Object> objectsList) {
        ObjectsList = objectsList;
    }
    private List<Object> ObjectsList;
}

The same problem, if you are trying to return a String, you cannot. You must create a StringContainer.

+10
source

I used a similar solution after much thought. Try the following:

public class JsonList<T> { 
private List<T> listItens;

public List<T> getListItens() {
    return listItens;
}

public void setListItens(List<T> listItens) {
    this.listItens = listItens;
}}

and in your method:

@ApiMethod(
        name = "name",
        path = "path",
        httpMethod = ApiMethod.HttpMethod.POST)
public CollectionResponse<Information> getInformation(JsonList<String> listOfItens) {}
+1

All Articles