Using v1/files to return a list of files

Started by bnewman, January 03, 2021, 06:44:14 AM

Previous topic - Next topic

bnewman

I want to use v1/files to obtain a list of files. For the id parameter, the script provides an array of file id's. This array is obtained, by a previously completed request of v1/categories requesting the field 'files'. When I provide this array to v1/files id parameter, the response is the list of all files in the database. Clearly, I'm misunderstanding the meaning of the id parameter. Can i do this operation?

The specific call is something like this:
               IMatch.get('v1/files',{
                  id: FileIDlist, //<------this is an array of file id's
                  sortby: 'datetime',
                  sortdir: 'desc',
                  fields: 'id,name,datetime'
                        }).then(function(response) {
                           // add id, name, and date of each file into a storage table
                           ...
                        }); //IMatch.get('v1/files'

I'm concerned that if i issue v1/files one element at a time, I will overflow the system with hundreds of IMatch.get requests all at once.


Mario

#1
id is not an array. It is a list of comma-separated file ids: "1,2,3,4,5". Example (using a more modern async/await approach):

const fileData = await IMWS.get('v1/files', {
    id: '1,2,3,4,5',
    fields: 'id,filename'
});
console.log(JSON.stringify(fileData,null,2));
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook