willlma
willlma

Reputation: 7543

More info on Cloud Endpoints return types

According to the documentation,

the return value type cannot be simple type such as String or int. The return value needs to be a POJO, an array or a Collection.

This is exactly how things work on the local dev server. However, once deployed, collections and arrays of primitive types result in a 500 Internal Server Error whether the GET URL is typed into the browser or the APIs explorer is used, despite the fact that server logs show 200 Success. Collections of POJOs work fine.

This has been the case for months and through several attempts with different methods. Is this the intended behaviour or is it a bug?

Upvotes: 2

Views: 1028

Answers (1)

Tom
Tom

Reputation: 17884

I think I encountered the same thing recently. I tried returning a collection or array of strings from an endpoint. It appeared to work - it generated my client code without errors and created code that appeared specifically designed to handle the type (in other words, yes, they meant for it to work). However, once deployed it didn't work.

Eventually I turned up a SO Q/A from the spring (can't find it now) in which Google became aware of the bug, but I guess they still haven't fixed it or changed the docs.

[edit: I found the post I was thinking of]. In this post from 2013-03, Dan Holevoet of Google initially suggests using a collection of entities, but finds that this doesn't work, so suggests as a work-around that the collection be wrapped in a temporary class. That, plus my experience above (it generated a StringCollection, as I was attempting to use a collection of strings), is what lead me to conclude that it is a known issue.

Upvotes: 1

Related Questions