Returns every folder as a flat list -- there's no nested-tree shape from the API itself. Build the hierarchy on your own side using parentFolderId.
Having trouble reaching the API, or logging in from another machine? See Network Access & Authentication Security -- by default the Api only answers
localhost, and PowerShell needs an extra flag once it does answer elsewhere.
Order of Operations
- Authenticate to the API.
- Request the folder list.
The call
GET /api/folders
No route parameters, no query parameters, no request body.
Permission needed: Job.View.
C# example
var jsonOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web);
// Step 1: Authenticate to the API.
using var handler = new HttpClientHandler { UseDefaultCredentials = true };
using var client = new HttpClient(handler) { BaseAddress = new Uri("http://your-minion-agent-server:5443") };
client.DefaultRequestHeaders.Add("X-App-Name", "MyIntegration");
// Step 2: Request the folder list.
var folders = await client.GetFromJsonAsync<FolderSummary[]>("/api/folders", jsonOptions);
foreach (var folder in folders!)
{
Console.WriteLine($"{folder.FolderID}: {folder.FolderName} (parent: {folder.ParentFolderID?.ToString() ?? "root"})");
}
record FolderSummary(int FolderID, string FolderName, int? ParentFolderID);
Not on a domain machine? Swap in the app-account login from Calling the API From Your Own Code.
PowerShell example
# Step 1: Authenticate to the API.
$headers = @{ "X-App-Name" = "MyIntegration" }
# Step 2: Request the folder list. (-AllowUnencryptedAuthentication: PowerShell requires this for Windows auth over plain http to anything but localhost -- see "Network Access & Authentication Security".)
$folders = Invoke-RestMethod -Uri "http://your-minion-agent-server:5443/api/folders" -UseDefaultCredentials -AllowUnencryptedAuthentication -Headers $headers
$folders | ForEach-Object { "$($_.folderID): $($_.folderName) (parent: $($_.parentFolderID))" }
What you get back
200 OK, an array, ordered by name:
[
{ "folderID": 3, "folderName": "ETL", "parentFolderID": null },
{ "folderID": 8, "folderName": "Nightly", "parentFolderID": 3 }
]
Codes this call can return
See API Response Codes for what each one means in general. For this specific call:
- 200 -- the list, even if it's empty.
- 403 -- you don't have
Job.Viewanywhere.
See also: Create a Folder.