Multiple Entity arguments in Google Cloud Endpoints

后端 未结 2 1352
长发绾君心
长发绾君心 2020-12-16 07:52

How can I pass more than one Entity from a client to a Google Cloud Endpoint?

For example, passing a single Entity is easily done in an Endpoint api source file in t

相关标签:
2条回答
  • 2020-12-16 08:15

    Use the 'named' annotation...

    @ApiMethod(name = "sendStuff")
    public void sendStuff( @Named("clientId") String clientId, @Named("stuff") String stuff )
    

    And for android, the client code would look like this

    SendStuff sl = service.sendStuff( clientId, stuff );
    
    0 讨论(0)
  • 2020-12-16 08:23

    You can't send multiple entity types in the body of your request. You'll need to create a wrapper entity that contains those two entities, e.g.:

    class MyWrapperEntity {
      MyEntity someEntity;
      MyOtherEntity someOtherEntity;
      // ...
    }
    

    However, that's not what your example shows (the entities are the same type). Use a List<MyEntity> or Map<String, MyEntity> inside of a collection entity instead, e.g.:

    class MyEntityCollection {
      List<MyEntity> items;
      // ...
    }
    
    0 讨论(0)
提交回复
热议问题