KNOWLEDGE PORTAL

Folder Information

Summary

**Do not use in production environment without professional assistance**

When creating a folder, it is just as important to know what the API is looking for as it is to be able to make the API call to create the folder.  Below is an example of how to get the Stub of the folder so that you know how to form the API call to create the folder.

To view this script on the Cyberhill Github page, click here.


Function Get-SSFolderStub {
    Param
    (
         [Parameter(Mandatory=$true, Position=0)]
         [string] $URI,
         [Parameter(Mandatory=$true, Position=1)]
         [string] $APIKey
    )

    try
    {
    $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
    $headers.Add("Authorization", "Bearer $APIKey")
    

    $diagnostics = Invoke-RestMethod "$URI/api/v1/folders/stub" -Method Get -Headers $headers
    return $diagnostics
    }
    catch
    {
        $result = $_.Exception.Response.GetResponseStream();
        $reader = New-Object System.IO.StreamReader($result);
        $reader.BaseStream.Position = 0;
        $reader.DiscardBufferedData();
        $responseBody = $reader.ReadToEnd() | ConvertFrom-Json
        Write-Host "ERROR: ($responseBody.error)"
        return;
    }
} 
You might also be interested in
Pulling a User Account
When working with Secret Server it is important to know what groups and roles a user is part of.
LEARN MORE
Getting a Token for Use With the API
To start using the API you need to get a token. There are a few ways to do this.
LEARN MORE
Pulling a Secret from Secret Server by ID
One of the most common things clients look to do when scripting is to pull a secret from Secret Server. 
LEARN MORE