I wrote a dirty script in powershell for this some time ago... Maybe it can help you. It was:
# Settings
$SMBaseURL = 'https://smartermail.url/api/v1';
$APIUsername = 'someadminuser'
$APIPass = 'somepass'
$global:Header = ""
# Functions
function RestoreFolder($Account, $Folder, $Recursive)
{
# Rebuild user folder
$SMURL = "$SMbaseurl/settings/sysadmin/restore-folders"
$params = @{
"restorations" = @(
@{
"email" = $Account
"folder" = $Folder
"recursive" = $Recursive
}
)
}
$params = ConvertTo-Json -InputObject $params
$response = Invoke-RestMethod -Method POST -Headers $Header -ContentType "application/json" -uri $SMURL -Body $params -ErrorAction SilentlyContinue -ErrorVariable RestError
if ($response.success = $true -And (-not [string]::IsNullOrWhiteSpace($response.message)))
{
return "Error: " + $response.message
}
return "Ok."
}
#
# Main code
#
# Authenticate and get token
$SMURL = "$SMBaseURL/auth/authenticate-user"
$params = @{
username = $APIUsername
password = $APIPass
} | ConvertTo-Json
$response = Invoke-RestMethod -Method POST -ContentType "application/json" -uri $SMURL -Body $params -ErrorAction SilentlyContinue -ErrorVariable RestError
#Write-Host $response.accessToken
if ($response.resultCode = 200)
{
$accesstoken = $response.accessToken
$refreshtoken = $response.refreshToken
$Header = @{Authorization = "Bearer " + $accesstoken}
}
else {
Write-Host "Error: Could not authenticate on ${SMURL}"
exit
}
# Now lets give it a go...
RestoreFolder "someuser@domain.xxx" "Inbox" $true
Sébastien Riccio
System & Network Admin
https://swisscenter.com