简体   繁体   中英

Google Cloud Endpoint Illegal Argument exception on Android

I'm developing an Android application that uses for the back-end an app developed in Google App Engine and the API to that app is developed using Google Cloud Endpoints.

I have a method that requires a number of parameters, out of which one is an object. Right now I'm getting an Illegal Argument Exception when doing the call on Android, but this endpoint works on both an iOS app and through the Google API Explorer.

The method definition on the server side is:

@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
        )

And the call on the Android app is:

        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);

The FriendInvites contains 2 lists:

  • A list of Integers
  • A list of some other objects.

Any ideas about what might be wrong? Might be due to the way the object is serialized?

In my case apparently it was something weird happening when I added the second boolean variable to the parameter list. I solved the problem by creating a simple wrapper object that contained all the fields required by my method and used that to pass it from the Android client to the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM