REST API sorting

Hello everyone.

I am using mfiles as my file storage. I communicate with it strictly by REST API for which I created middleware on Azure. As number of files grows, I realize I have a problem.

The rest api is returning me only X files. Of course, there is the limit parameter, but a lot of files means slower system. My first idea was to use some sort of paging, but I realize that mfiles rest api don't have anything like that. My other idea was to only fetch X LATEST files (latest meaning youngest). As I were exploring this way, I also couldn't find anything that would let me sort files by property - in my case created date.

What are my options?

Thank you all and have a successful day.

Parents
  • At the moment there is no option to support sorting of search results on the server side when using the REST API. Basically you have to get all candidates and sort them yourself in your code. If there are more candidates than can be returned by a single search, you have to make multiple searches to get all the results.

    However you should not need to sort the results if your search only returns the latest files directly. Have you tried setting a search condition with the Created property so that you search for the documents created in, say, the last 7 days? That would be a property condition such as p20>=2025-04-08 (Created property has ID 20).

    Searching using the M-Files Web Service (REST API) on the Developer Portal has more information on the search conditions.

Reply
  • At the moment there is no option to support sorting of search results on the server side when using the REST API. Basically you have to get all candidates and sort them yourself in your code. If there are more candidates than can be returned by a single search, you have to make multiple searches to get all the results.

    However you should not need to sort the results if your search only returns the latest files directly. Have you tried setting a search condition with the Created property so that you search for the documents created in, say, the last 7 days? That would be a property condition such as p20>=2025-04-08 (Created property has ID 20).

    Searching using the M-Files Web Service (REST API) on the Developer Portal has more information on the search conditions.

Children
No Data