Workaround for 'Failed to update settings' Error in SMTP Settings Within Standalone Orchestrator

How to update SMTP settings when encountering the 'Failed to update settings' error in the Administration dashboard?

Issue Description

Users are unable to save SMTP settings through the web application due to a current bug.

A known issue in the web application prevents users from saving SMTP settings, resulting in the error message "Failed to save settings."

A fix is scheduled for an upcoming Cumulative Update (CU). In the meantime, it is recommended to use a provided PowerShell script as a workaround. This script will allow the manual update of the SMTP settings.

Resolution

  1. Obtaining the Bearer Token:
  • Log into the web platform as a host user.
    1. Open the browser’s developer tools and go to the Network tab.
    2. Refresh the page.
    3. Filter the entries for "token" in the Network tab's filter box.
    4. Click on the relevant entry and navigate to the 'Preview' tab.
    5. Right-click on the access_token field and select "Copy Value".


  1. Preparing the Script:
  • Copy the provided smtp_update.ps1 PowerShell script below into notepad
    <#
    .SYNOPSIS
    This script updates SMTP settings via an API call for UiPath's Orchestrator/Platform
    

    .DESCRIPTION
    The script reads configuration from a JSON file and makes a PUT request to update SMTP settings. It handles errors and outputs relevant information for troubleshooting.

    .EXAMPLE
    .\smtp_update.ps1
    #>

    Function to update SMTP settings

    function Update-SmtpSettings {
    param (
    [Parameter(Mandatory=$true)]
    [string]$configPath
    )

    try {
        Write-Host "Reading configuration from JSON file..."
    
        $config = Get-Content -Path $configPath | ConvertFrom-Json
    
        $url = $config.FQDN + $config.ApiEndpoint
        $headers = @{
            'authority' = $config.FQDN.TrimStart("https://")
            'accept' = 'application/json'
            'accept-language' = 'en-US,en;q=0.6'
            'authorization' = "Bearer $($config.BearerToken)"
            'content-type' = 'application/json; charset=UTF-8'
        }
    
        $data = $config.Data | ConvertTo-Json
    
        Write-Host "Updating SMTP settings..."
        $response = Invoke-RestMethod -Uri $url -Method Put -Headers $headers -Body $data -ErrorAction Stop
        Write-Host "SMTP settings updated successfully."
        
        # Output the response or process it as needed
        $response
    }
    catch {
        Write-Host "An error occurred: $($_.Exception.Message)"
        Write-Host "Stack Trace: $($_.Exception.StackTrace)"
        exit 1
    }
    

    }

    Main script execution

    $scriptPath = “smtp_config.json” # Replace with the actual path
    Write-Host “======= SMTP Settings Update Script =======”
    Update-SmtpSettings -configPath $scriptPath
    Write-Host “===========================================”

  • Ensure the script is saved in a known, accessible location on your local machine.

  1. Preparing and Editing the Config File:
  • Copy the provided smtp_config.json file below into notepad
    {
        "FQDN": "https://",
        "ApiEndpoint": "/identity/api/Setting",
        "BearerToken": "",
        "Data": {
            "Settings": [
                { "Key": "Email.Smtp.Domain", "Value": "" },
                { "Key": "Email.Smtp.EnableSsl", "Value": "false" },
                { "Key": "Email.Smtp.FromDisplayName", "Value": "" },
                { "Key": "Email.Smtp.FromEmail", "Value": "" },
                { "Key": "Email.Smtp.Port", "Value": "" },
                { "Key": "Email.Smtp.UseDefaultCredentials", "Value": false },
                { "Key": "Email.Smtp.UserName", "Value": "" },
                { "Key": "Email.Smtp.Password", "Value": "" },
                { "Key": "Email.Smtp.Host", "Value": "" }
            ],
            "PartitionGlobalId": ""
        }
    }
  • Locate the smtp_config.json file, which should be in the same directory as the smtp_update.ps1 script.
    • Open the file in a text editor.
    • Paste the copied Bearer Token into the "BearerToken" field.
    • Fill out the rest of the configuration file as needed for your SMTP settings.

  1. Setting the PowerShell Execution Policy (if needed):
  • Open PowerShell as an administrator.
    • Check the current execution policy by running:
      Get-ExecutionPolicy
    • If the policy is more restrictive than RemoteSigned, change it by running:
      Set-ExecutionPolicy RemoteSigned.
    • Note: Remember to reset the execution policy back to its original state after running the script, if you had to change it.

  1. Running the Script:
  • Navigate to the directory containing the smtp_update.ps1 script in PowerShell.
    • Run the script by typing .\smtp_update.ps1 and pressing Enter.
    • Follow any on-screen instructions to complete the process.

  1. Reverting the Execution Policy (if changed):
  • If the execution policy has been changed earlier, revert it to its original setting (noted in step 4) using:
    Set-ExecutionPolicy 
    • replacing with the policy noted earlier.