Dim requestAuthentication As New RequestAuthentication() requestAuthentication.username = "admin" requestAuthentication.password = "admin123*" client.Headers.Add(HttpRequestHeader.ContentType, "application/json") Dim jsonStr As String = client.UploadString("http://localhost:9998/api/v1/auth/authenticate-user", JsonConvert.SerializeObject(requestAuthentication)) Dim responseAuthentication As ResponseAuthentication = JsonConvert.DeserializeObject(Of ResponseAuthentication)(jsonStr) accessToken = responseAuthentication.refreshToken Dim requestRefreshToken As New RequestRefreshToken() requestRefreshToken.token = responseAuthentication.refreshToken client.Headers.Add(HttpRequestHeader.ContentType, "application/json") jsonStr = client.UploadString("http://localhost:9998/api/v1/auth/refresh-token", JsonConvert.SerializeObject(requestRefreshToken)) Dim responseRefreshToken As ResponseRefreshToken = JsonConvert.DeserializeObject(Of ResponseRefreshToken)(jsonStr) accessToken = responseRefreshToken.accessToken client.Headers.Add("Authorization", accessToken) Dim requestRestoreFolders As New RequestRestoreFolders() requestRestoreFolders.restorations = New Restorations() With { .email = "bruno@zagloman.com", .folder = "Inbox", .recursive = False } jsonStr = client.UploadString("http://localhost:9998/api/v1/settings/sysadmin/restore-folders", JsonConvert.SerializeObject(requestRestoreFolders)) Dim responseRestoreFolders As ResponseRestoreFolders = JsonConvert.DeserializeObject(Of ResponseRestoreFolders)(jsonStr)
By reporting abuse, a moderator will be asked to review the content of this interaction to take further action, if necessary.
# 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
Trouble logging in? Simply enter your email address OR username in order to reset your password.
For faster and more reliable delivery, add noreply@smartertools.com to your trusted senders list in your email software.
A code was sent to the recovery email address. Please provide the 6-digit code.
A code can be retrieved from your authentication app. Please provide the 6-digit code.
An email was sent to your recovery email address. If you need further assistance, please contact your system admin.
Passkeys let you sign in quickly and securely using your fingerprint, face, or device PIN. No password needed!