Using pageSize and offset in REST API

Hi.

I have 14 rows in one table, and when i perform a query using REST API, i get back first 10 results and an url in nextPage param. I have checked documentation and pageSize and offset params are used for this, but in my request i am not setting any value for both params, so 10 results must be the default number. Is there a way to change that value?

I am also using Android and iOS SDK. Do they also have 10 as the default number of results? If i perform a query that returns more than 10 results, how is it handled?

Regards,
Andrés

Hi Andrés,

Yes, the value of 10 is used by default on the server. You can override id with the pageSize option.

Regards,
Mark

Hi Mark.

Can i set any value i want in pageSize? Let´s say 100 …

Regards,
Andrés

Hi Andrés,

Anything less than 100. If you set a value greater than 100, it will “throttle” it to 100 anyway.

Regards,
Mark

Ok, so 100 is the limit. I will try with that.

Thanks Mark.

Regards,
Andrés

Hi Mark.

How does this limit is applied in relationships? If i have table A with a one-to-many relationship with table B, and i make a query to table A using load properties to get that relationship, how can i retrieve all the objects if that relationship has more than 100 objects?

Regards,
Andrés

Hi Andrés,

Currently, this limit not applied in relationships.
We will add this limit (max page size 100 for related objects) in the next iteration.

Regards,
Kate.

hello sir/mam ,
i uploaded about 100 image file at backendless. how to get these image first time 20 and next 20-20… in swipe to refreshing technique. but i don’t know where to put swipe to refreshing code. here is my code

public void fetch() throws InterruptedException {
Log.e(“fetch”, “called”);
final int PAGESIZE = 20;
final BackendlessDataQuery dataQuery = new BackendlessDataQuery();
dataQuery.setPageSize(PAGESIZE);
dataQuery.setOffset(dataObject.size());
final AsyncCallback<BackendlessCollection<ImageTable>> callback = new AsyncCallback<BackendlessCollection<ImageTable>>() {
private int offset = dataObject.size();
private boolean firstResponse = true;

    @Override
    public void handleResponse(BackendlessCollection&lt;ImageTable&gt; response) {
        if (firstResponse) {
            firstResponse = false;
        }
        progressBar.setVisibility(View.GONE);
        imageTableList = response.getCurrentPage();
        if (imageTableList.size() > 0) {
            offset += response.getCurrentPage().size();
            response.getPage(PAGESIZE, offset, this);
            for (int i = 0; i < imageTableList.size(); i++) {
                ImageTable imageUrl = imageTableList.get(i);
                if (imageTableList.get(i) != null && imageUrl.typeData == 0) {
                    final Bitmap lowBitmap = decodeBase64(imageUrl.getLowImageUrl());
                    final Bitmap lowBlurBitmap = new Blur(MainActivity.this, 25).transform(lowBitmap);
                    imageUrl.setLowq(lowBlurBitmap);
                }
                dataObject.add(imageUrl);
            }
            imageAdapter.notifyDataSetChanged();
        } 
    }

    @Override
    public void handleFault(BackendlessFault fault) {
        Log.e("fetch", fault.getCode() + "");
        if (fault.getCode().equals("Internal client exception")) {
            progressBar.setVisibility(View.GONE);
            Toast.makeText(MainActivity.this, "Network Error! Swipe down to load", Toast.LENGTH_SHORT).show();
        }
    }
};
try {
    Backendless.Data.of(ImageTable.class).find(dataQuery, callback);
} catch (Exception e) {
}

}