【问题标题】:Google Cloud Endpoint Illegal Argument exception on AndroidAndroid 上的 Google Cloud Endpoint Illegal Argument 异常
【发布时间】: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


    【解决方案1】:

    在我的情况下,当我将第二个布尔变量添加到参数列表时,显然发生了一些奇怪的事情。我通过创建一个简单的包装对象解决了这个问题,该对象包含我的方法所需的所有字段,并使用它将它从 Android 客户端传递到服务器。

    【讨论】:

      猜你喜欢
      • 2014-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多