Kevin Ko Kevin Ko - 4 months ago 53
Android Question

How can Android get the multiple values from the custom API using InvokeAPI method

I'd like to get the customer search results from the custom API in the Azure Mobile Service. When I check the custome API using the Fiddler, it returns multiple search results. But my Invoke API only get the one result. How I can get the all results? My Azure-Mobile-Android SDK is 3.1.0

ListenableFuture<jsonelement> response = mClient.invokeApi("customersearch", request, JsonElement.class);

Futures.addCallback(response, new FutureCallback<jsonelement>() {
@Override
public void onSuccess(JsonElement response) {
Log.d("Debug","Response received!!! " + response.toString());

}

@Override
public void onFailure(Throwable throwable) {

createAndShowDialog((Exception) throwable, "Wakeup Error");

}
});

Answer

@KevinKo, I viewed the source code MobileServiceClient.java, then I found the function invokeApi return multiple entities or only one entity via the function Class.isArray() for the parameter final Class<E> clazz.

So please use JsonElement[].class instead of JsonElement.class to try again.