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 the server:
public class SomeEndpoint {
...
@ApiMethod(...)
public MyEntity someMethod(MyEntity someEntity) {
...
}
...
}
then in a client I could easily call
endpoint.someMethod(someEntity).execute()
But, what if I want to pass two entities to an endpoint?, like this:
@ApiMethod(...)
public MyEntity otherMethod(MyEntity someEntity, MyEntity someOtherEntity) {
...
}
this doesn't work, GPE only generates an endpoint library with a single MyEntity argument.
Is it possible to pass multiple Entity arguments?
Thanks.
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;
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With