Remove Host Records from Folder ​
DELETE /winapi/hostsinfolders
Removing a Host record from beneath a Host Folder is possible by submitting a 'DELETE' HTTP Verb to the API. When the Host record is removed, you will be returned a Http Status Code of 204 - NoContent. No host records are deleted here, instead they are removed from the Hosts Folder view in the UI.
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'
- The user must also have access to the Host Folder itself
Powershell
# Remove using HostName
$Body = @{
HostName = "webserver01.domain.net"
DeleteFromFolderID = "4490"
}
$jsonData = $Body | ConvertTo-Json
# Remove using HostID
$Body = @{
HostID = "3523"
DeleteFromFolderID = "4490"
}
$jsonData = $Body | ConvertTo-Json
$PasswordstateURL = 'https://passwordstate/winapi/hostsinfolders/'
Invoke-Restmethod -Method Delete -Uri $PasswordstateURL -ContentType "application/json" -Body $jsonData -UseDefaultCredentialsJson
# Response
HTTP/1.1 204 No Content