API filter and pagination

1.  I want to be able to filter clients based on a custom-text and return two entries.


It appears the only way I can achieve this is to return the entire client database and then apply the filtering locally.  This does not seem correct.


2.  Is there a way to use "wild card" or regex expression criteria to strings when using the filter logic?  Again, it appears the only solution is to return the entire client database.


Are these two fundamental weaknesses in the API design?


3 people have this question

Hello David,


Did you get a chance to try the Filter Contacts API? I think this will suit your requirement as you can search for contacts based on a custom text field value. Give it a try and let me know how it goes.


Cheers!

The first point has been resolved, but the second point is outstanding in respect to being able to use "Wild Card" or regex expressions to match a string.

Sorry, the first point has not been resolved as you cannot use the page size option with the Filter Contacts API?


I have just tried the following query


https://<domain>.freshdesk.com/api/v2/search/tickets?per_page=3&page=2&query="agent_id%3E1"


I get the following response


{

description"Validation failed",

errors

[

{

field"per_page",

message"Unexpected/invalid field in request",

code"invalid_field"

}
]

}

Hello David, 


At the moment, you cannot perform a REGEX search in Freshdesk (it's one of the popular requests in the community). However, the Filter contacts API should support page and per_page params in the request. Can you please modify your request to include the page params at the end of the call, after the query string?


For example,


https://<domain>.freshdesk.com/api/v2/search/tickets?query="agent_id%3E1"&per_page=3&page=2


Cheers!

I have the same problem when adding the per_page parameter to a query. I've structured it to match the example above, but get the same result: "field":"per_page","message":"Unexpected/invalid field in request","code":"invalid_field"


It works fine with this:

/api/v2/search/tickets?query="created_at:>%272018-02-01%27"

But returns the 400 error when I add the per_page parameter:

/api/v2/search/tickets?query="created_at:>%272018-02-01%27"&per_page=100

 Have I done something wrong in this query? I'm trying to export a large number of tickets, so want to increase the number of tickets per page rather than perform a ton of requests.


Cheers!


I'm also finding that there is no link in the headers when I add a query to the API call. The pagination only seems to work for me if I don't use query=...

 

This returns a page of 30 results with no link in the headers:

/api/v2/search/tickets?query="created_at:>%272018-02-01%27"


But this returns a page of 30 results with a link in the headers, which I can call again and receive up to 9000 items correctly.  

api/v2/tickets?updated_since=2018-02-01T00:00:00Z

  

Did you manage to resolve this? I'm having the same issue as Dave CK where adding the "per_page" bit is causing 400 errors.


Even as something as simple as 

api/v2/search/tickets?query="status:2"&per_page=3&page=2

 

As followed from the documentation is erroring.


Is there something I'm doing wrong?


Thanks!

Any success with this? I too am having an issue with per_page.  

/api/v2/search/tickets?query="status:4"&per_page=30';

  Getting bad request from this."page" is working fine.

I have also hit this issue:

https://domain.freshdesk.com/api/v2/search/tickets?per_page=30 


{
    "description": "Validation failed",
    "errors": [
        {
            "field": "per_page",
            "message": "Unexpected/invalid field in request",
            "code": "invalid_field"
        }
    ]
}

Same thing here, per_page isn't working for 

https://domain.freshdesk.com/api/v2/search/tickets


@freshdesk, any updates?

Still an issue for us. Please fix this, Freshworks.

I submitted a ticket and had it confirmed that 300 total tickets (30 per page and 10 pages) is the current max results from a single Filter Tickets query (/api/v2/search/tickets). Increasing the per page amount is apparently not a supported option any longer with this specific API. I was provided a few suggestions that some here might find helpful.


1) Split your search into multiple queries until the results are under 300 each then combine the tickets. The Total attribute returned on filtered queries will let you know the actual number of tickets and can be used to keep narrowing the query until you get it below 300.


2) Use the List All Tickets API which only supports limited filtering to return up to 9,000 tickets then sort out the appropriate tickets you want later. I don't think this would work well for my situation as I likely wouldn't find all of the necessary results in the 9k tickets. It would also be many wasted calls and you could potentially hit your rate limit quite fast if you have many different filtered results you are seeking and need to pull 9k for every one of them.


3) Use the Scheduled Exports feature under the Reports/Analytics screen. This has it's own limitations like only being able to save 5 unique exports and no access to multi-line text fields.


None of these are great answers, but I think #1 might be viable. It's still frustrating that the page limit can't just be increased. There would be the same overall rate limit so you wouldn't cause resource issues for Freshdesk. Also if we can narrow the queries and run more of them in succession to get similar results, why not just give us those results in one query with more than 10 pages? I can see per_page being an issues as they have to return many more results per call, but it seems the max number of pages could go much higher as it would still be a separate call for each page and consume the same amount as splitting the queries.

Login or Signup to post a comment