0
votes

I have the following cloud endpoint:

@ApiMethod(name = "test.insert")
public Test insertTest(final Test test)
{
// test is Test here, but not null
}

I pass null as parameter on the Android client:

api.test().insert(null).execute();

On the backend, a Test object is created, where all fields are null. But the object itself is not null.

  • How can I test the object for null or prevent null to be passed into the API?

I know I can make @Named parameters @Nullable, but for the object parameter it looks like GCE or REST does not reconstitute null objects as expected.

1
did you ever find this out? how to set constraints to the objects we send in the body and their fields? - Ulises CT
We finally gave up on Google Could Endpoints and switched to Spring, best decision we could have ever made. Cloud Endpoints has a lot of sick behavior like you return an empty array on the server and receive null on the client. Don't use it. - Oliver Hausler

1 Answers

-1
votes

Use com.google.api.client.util.Data.isNull method to check the value is null.