Getting started with the DBServer API from script

I was trying to get the items from a specific folder via script. I started with the jukebox script, but apparently the API has changed (I’m currently on 6.1.0).

The following statement is returning all items in the database:

items := IDBConnection(Database(0)).ProcessRequest('GET', '/items?folder=' + FolderID, nil, nil, nil).AsArray;  

The logging of the database server is stating the following request: /api/v1/items?station=1 and so the folder parameter is being ignored.
Can someone get me started with this? Purpose is to get an item from a folder and use it in case of an underrun.

Thanks!

The internal API behind ProcessRequest ist very similar to HTTP (so it can be translated to HTTP easily), but it is not exactly the same. Parameters must not be passed as part of the URL, but rather in the “Parameters” parameter (haha), the one after URL. You must use an IStrings object for that:

var 
  params: IStrings; 
  [...]

begin
  [...]
  params := Factory.CreateStrings;
  params.AddValue('folder', folderID);
  items := IDBConnection(Database(0)).ProcessRequest('GET', '/items', params, nil, nil).AsArray;  
  [...]
end.

On a side note, in v6.1 the IDBConnetion interface has a convenient function that wraps the ProcessRequest call and even translates the returned IPersistentArray into a propert IPlaylist object:

    function GetFolderContent(iID: string): IPlaylist;

Thanks! You’re my hero!