Showing results for 
Search instead for 
Did you mean: 

NetBackup API filter and page[offset] / page[limit] does not work


I'm new to NetBackup API but I have decent experience with REST API and I have problem with the NetBackup API that only returns the first 10 records (default value of the call). The two calls I tried is "/netbackup/admin/jobs" and "/netbackup/catalog/vmware-images" and no matter what I set for the page[offset] / page[limit], it only return the same 10 records. Also the filter has no effect on the call, seems like it ignores the filter. Here is the excerpt of the code (sorry it's not python but you can get the idea):

var restHost = RESTHostManager.createHost(host);
restHost.url = '';

var token = getToken();

var catOffset = 0;
var vmSubUrl = '/netbackup/catalog/vmware-images';
while (next) {
    var catParams = {"page[offset]":catOffset, "page[limit]":catLimit, "filter":"(vCenter eq 'vcentername.local')"};
    var getVMsRequest = restHost.createRequest("GET", vmSubUrl, catParams);
    getVMsRequest.setHeader("Authorization", token);

    var getVMsOutput = getVMsRequest.execute();
    if (getVMsOutput.statusCode == 200) {
        var getVMJSON = JSON.parse(getVMsOutput.contentAsString);
        catOffset += getVMJSON['meta']['pagination']['limit'];
        next = getVMJSON['meta']['pagination']['next'] == 10;

        for each (var vm in {
            System.debug('\t[+] VM Name:\t' + vm["attributes"]["vmHostName"]);
            System.debug('\t[+] vCenter:\t' + vm["attributes"]["vCenter"]);
    else {
        message = getVMsOutput.contentAsString;
        System.debug("Error: " + message)
        next = false;

At one point the calls works fine, then the NetBackup admins update the Java and Tomcat after that the call just returns the last 10 records. I'm not sure that the version changed or not but I cannot see why it keeps return the same 10 records.


2 Replies

Re: NetBackup API filter and page[offset] / page[limit] does not work

The trick with the filters is making sure they adhere to the OData standards and are part of the URL string itself.  Using our Swagger interface where I set the page limit to 50, the URL generated looks like this:

Notice how the brackets are %5B and %5D and the filter string is part of the URL itself. I recently wrote a Python script that made a call to the /catalog/images API where I needed to set the page limit and filter on client name and a time parameter.  I found that I had to run this through the quote method from the urlllib library.  Here's a code snippit on how I built the URL and called it:

from datetime import datetime, timedelta
import requests
from urllib.parse import quote

uri = "https://nbu8301:1556/netbackup/catalog/images"
header = {
currentDate = datetime.utcnow()
backupTimeStart = currentDate - timedelta(days=30)
filter="filter=clientName eq 'centos7' and backupTime ge {}Z".format(backupTimeStart)
respone=requests.get(url, headers=header, verify=False)

Here's the difference on the URL before and after running through the quote method:

URL before using quote method
https://nbu8301:1556/netbackup/catalog/images?page[limit]=50&filter=clientName eq 'centos7' and backupTime ge 2020-09-23 15:44:16.678827Z

URL encoded with quote method

I think if you change your code to concatenate your filters onto the URL and properly URL encode the filter, this might work better for you.

Tom Simerson

Re: NetBackup API filter and page[offset] / page[limit] does not work

Thank you, Tom. I will try that.