Eliot
Eliot

Reputation: 2429

What parameter types are supported by Google Endpoints in an API method?

I can make String, Date and Long work. If I use byte[] I get an error when I run the endpoints.sh script. I can find nothing in the documentation that lists the types supported and the errors generated a pretty cryptic. I'd like to get a little bit of binary (image) data into an endpoint method. This is no good:

@ApiMethod(name = "device.bikeImage.set")
public void setDeviceBikeImage(com.google.appengine.api.users.User appEngineUser,
        @Named("facebookAccessToken") @Nullable String facebookAccessToken,
        @Named("deviceId") String deviceId, @Named("bikeImage") byte[] bikeImage)
        throws IOException, OAuthRequestException {
}

What types are supported?

Upvotes: 2

Views: 1526

Answers (2)

nilsmagnus
nilsmagnus

Reputation: 2322

The datatypes supported are described in the docs for endpoints, right here.

The supported parameter types are the following:

java.lang.String java.lang.Boolean and boolean
java.lang.Integer and int
java.lang.Long and long java.lang.Float and float
java.lang.Double and double
java.util.Date
com.google.api.server.spi.types.DateAndTime
com.google.api.server.spi.types.SimpleDate
Any enum
Any array or java.util.Collection of a parameter type

Upvotes: 2

jdub
jdub

Reputation: 133

The following article has a list of the value types that are supported (go to the "Properties and Value Types" section:

https://developers.google.com/appengine/docs/java/datastore/entities

When working with Endpoints, you are definitely limited to only those types that can be serialized into JSON.

There is also minimal discussion on serving blobs from Endpoints in these two questions:

  1. How can I upload an thumbnail image (blob) at the same time as an Entity into a datastore in google app engine?

  2. Serving blob from app-engine endpoint

Upvotes: 0

Related Questions