Add Host Folder ​
POST /winapi/hostfolders
Adding a new Host Folder object can be achieved by making a POST request on the URL, with appropriate fields forming the HTTP message body.
The user executing the API script must be given access to the following:
- On the screen Administration -> Feature Access -> Hosts tab : 'Specify which users are allowed to have access to the main Hosts Menu'
- On the screen Administration -> Feature Access -> Hosts tab : 'Specify which users are allowed to add/edit/delete Folders within the Hosts Menu, as well as manage permissions on these Folders'
The PowerShell example below creates a Host Folder record with various fields specified.
Powershell
#JSON data for the object
$Body = @{
FolderName = "Test Folder"
Description = "All Microsoft database servers"
DatabaseServerType = "SQL Server"
PropagatePermissions = "False"
NestUnderFolderID = "0"
SiteID = "0"
}
$jsonData = $Body | ConvertTo-Json
$PasswordstateURL = 'https://passwordstate/winapi'
$result = Invoke-Restmethod -Method Post -Uri $PasswordstateURL'/hostfolders' -ContentType "application/json" -Body $jsonData -UseDefaultCredentials
Write-Output $resultJson
# Response
HTTP/1.1 200
[
{
"FolderID":"12345",
"FolderName":"Microsoft Database Servers",
"Description":"All Microsoft database servers",
"TreePath":"\",
"PropagatePermissions":"False",
"HostNameMatch":"",
"TagMatch":"",
"HostType":"All Host Types",
"OperatingSystems":"",
"DatabaseServerType":"SQL Server",
"SiteID":"0",
"SiteLocation":"Internal"
}
]