【发布时间】:2014-12-09 13:50:57
【问题描述】:
我正在开发一个 Android 应用程序,该应用程序将在 Google App Engine 中开发的应用程序用作后端,并且该应用程序的 API 是使用 Google Cloud Endpoints 开发的。
我有一个需要多个参数的方法,其中一个是对象。现在,我在 Android 上进行调用时遇到了非法参数异常,但此端点可在 iOS 应用程序和 Google API Explorer 上运行。
服务端的方法定义为:
@ApiMethod(name="createEvent", httpMethod = HttpMethod.POST)
public EventResponse insertEvent(@Named("creatorId")long creatorId,
@Nullable @Named("title")String title,
@Nullable @Named("description")String description,
@Nullable @Named("maxPeople")int max_approved,
@Named("category")Constants.Category category,
@Named("latitude")float latitude,
@Named("longitude")float longitude,
@Nullable @Named("venue") String venue,
@Nullable @Named("fromTime")String time,
@Nullable @Named("toTime")String toTime,
@Nullable @Named("address")String address ,
@Named("fbToken")String authToken,@Nullable @Named("groupChatId")String groupId,
@Nullable @Named("dialogId")String dialogId,
@Nullable @Named("date")String givenDate,
FriendInvites inviteList,
@Named("isInviteOnly")boolean isInviteOnly,
@Nullable @Named("inviteAllWhostrFriends")boolean inviteAllWhostrFriends,
@Nullable @Named("hashTags")String hashTags
)
Android 应用上的调用是:
FriendInvites empty = new FriendInvites();
List<FacebookInvite> facebookList = new ArrayList<FacebookInvite>();
empty.setFacebookList(facebookList);
List<Long> ids = new ArrayList<Long>();
empty.setWhostrList(ids);
Eventendpoint.CreateEvent createEvent = service.createEvent(AppState.getInstance().getCurrentUser().getUserId().getId(),
category,
latitude,
longitude,
token,
true,
empty);
FriendInvites 包含 2 个列表:
- 整数列表
- 其他一些对象的列表。
对可能出现的问题有任何想法吗?可能是由于对象序列化的方式?
【问题讨论】:
标签: java android google-app-engine google-cloud-endpoints