How do I store multiple My Array entries from Azure Mobile using API code?

I created an API completeall2

in Azure Mobile service.

My API Coding

exports.post = function(request, response) {
var mssql = request.service.mssql;
var sql = "SELECT * from productmovement";
mssql.query(sql, {
    success: function(results) {            

                   response.send(200, results);

    }    })  };

      

What code is keeping this results

in mine ArrayList<ProductMovement>

in my application.

+3


source to share


2 answers


What I did to overcome this problem was to call another overload of invokeApi that returns a JsonElement and then deserializes it into my objects like this:



mClient.invokeApi("productmovement",new ApiJsonOperationCallback() {
    @Override
    public void onCompleted(JsonElement jsonElement, Exception e, ServiceFilterResponse serviceFilterResponse) {
        GsonBuilder gsonb = new GsonBuilder();
        Gson gson = gsonb.create();

        JsonArray array = jsonElement.getAsJsonArray();
        List<MyObject> myObjects = new ArrayList<MyObject>()>
        for(int i = 0; i < array.size(); i++)
        {
            myObjects.add(gson.fromJson(array.get(i).getAsJsonObject().toString(), MyObject.class));
        }
    }
});

      

+3


source


Refer to the mobile services help desk to request data from an Android client: https://azure.microsoft.com/en-us/documentation/articles/mobile-services-android-how-to-use-client-library/#querying



+3


source







All Articles