Skip to content
Advertisement

Error Invalid filter or pagination Issue node.js

I am writing a program that pulls data from an API and saves the data locally as a json file on my computer (to later be sorted and sent out again). My program was working fantastically until I tweaked a few settings and now I get the error ‘invalid filter or pagination input. and I’m not really sure what that means.

Here is my code that was working, it is the method that fetches history from an API:

historyModule
    .fetchAll({
        directions: [HistoryDirection.OUTGOING],
        types: [HistoryEntryType.CALL],
        connectionIds: ['p0', 'p70'],
        startDate: new Date('00-01-2022'),
//        endDate: new Date('01-07-2022')
    },
    {
        limit: 1000
    })
    .then(data => { 
//        console.log(data)
        let dataToString = JSON.stringify(data, null, 1)
        fs.writeFile("/mnt/c/Users/bradley.schapf/Documents/test.json", dataToString)
    })
    .catch(console.error)

As you can see, there are a few different elements for tweaking the result of the information, such as a limit to how many entries are fetched, date specification, and most importantly the ‘connectionIds’, which are the different users that I am pulling data from (a call history to be more exact).

at first I only used two users to test if it worked with the intention of adding many more users (connectionIds) to the list. so once it was working with two users I changed the following lines

        connectionIds: ['p0', 'p109', 'p111', 'p70'], //added two more users
        startDate: new Date('03-01-2022'),          //changed the date from January to March
        ...
        limit: 5000                                //upped the entry limit from 1000 to 5000

I’m not sure why but those three small changes just broke my program. I don’t see a reason why upscaling the data I’m fetching would produce an error. any pointers in the right direction or explanations about what the error really means would be greatly appreciated.

btw, this is my first question here so please forgive me for any mistakes or lack of clarity in my question 🙂

Advertisement

Answer

update, i figured out what the problem was. the API I was trying to access (SipgateIO) has data limitations, so my query ‘limit: 5000’ was above the allowed limit of 1000. I figured this out by testing different values until I figured out which changed value gave me the error.

Although I should mention that my workaround for this limitation was to create an array with all of the users I need to access data from, and just loop through the array and fetching data for each user and appending it to a JSON file.

btw, I’m not sure if it’s better for me to answer the question or just delete it since no one else gave answers or commented on it… maybe a mod could clarify that for me?

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement