When passing an object as a parameter to a cloud endpoint, it passes it as a payload and the app engine can't interpret it. However if you send each item of the object separately it works just fine.
@ApiMethod(name = "setFavorite", httpMethod = "post")
public void setFavorite(Photo photo, @Named("user") String user) throws IOException {
log.log(Level.WARNING, photo.toString());
photo.setOwner(user);
Entity photoEntity = new Entity("Photo");
photoEntity.setProperty("photoId", photo.getPhotoId());
photoEntity.setProperty("ownerId", photo.getOwner());
photoEntity.setProperty("photoName", photo.getPhotoName());
photoEntity.setProperty("albumName", photo.getAlbumName());
photoEntity.setProperty("photoThumbnail", photo.getPhotoThumbnail());
photoEntity.setProperty("isFavorite", true);
photoEntity.setProperty("photoUrl", photo.getPhotoUrl());
datastore.put(photoEntity);
}
public String photoName;
public String photoUrl;
public String albumName;
public int photoNumber;
public String photoThumbnail;
public boolean isFavorite;
public String ownerId;
public String photoId;
public Key photoKey;
The code that only sends the user and sends the photo object as a payload(which doesnt work):
var photoApi = document.getElementById('photoApi');
var request = photoApi.api.setFavorite({
user: gapi.auth2.getAuthInstance().currentUser.get().getId(),
photo: _photo
});
var photoApi = document.getElementById('photoApi');
var request = photoApi.api.setFavorite({
user: gapi.auth2.getAuthInstance().currentUser.get().getId(),
photoName: _photo.photoName,
photoId: _photo.photoId,
albumName: _photo.albumName,
photoThumbnail: _photo.photoThumbnail,
isFavorite: true,
photoUrl: _photo.photoUrl
});