REST API - Resolution for PASWS168E "Invalid Parameters" Error when calling the Idira PVWA REST API to cache SSH keys

REST API - Resolution for PASWS168E "Invalid Parameters" Error when calling the Idira PVWA REST API to cache SSH keys

122
Created On 11/10/26 10:54 AM - Last Modified 11/10/26 15:57 PM


Symptom


When using a PowerShell script to invoke the SSHKeys/Cache endpoint, the following error is returned:

{
  "Details": [
    {
      "ErrorCode": "PASWS168E",
      "ErrorMessage": "Input parameter for [formats] value is invalid",
      "ParameterName": "formats"
    }
  ],
  "ErrorCode": "PASWS167E",
  "ErrorMessage": "There are some invalid parameters"
}

 



Environment


12.2;12.6;14.0;14.2;14.4;14.6;15.0 Privileged Access Manager (PAM, self-hosted) Cyber-Ark API/SDK Cyber-Ark API/SDK REST API

Cause


The error is primarily caused by one or both of the following:

  1. Incorrect Parameter Name: The API expects formats (plural) rather than format (singular) when requesting specific key types.

  2. Incorrect Data Type: The formats parameter must be passed as an array of strings (enclosed in square brackets []), even if only one format is requested.

  3. Missing Key Password: For certain formats like OpenSSH or PPK, a keyPassword parameter is required in the request body.



Resolution


Correct Request Body Structure

To successfully retrieve an OpenSSH or PPK key, the JSON body must include the formats array and a keyPassword.

Example JSON Body:

{
  "formats": ["OpenSSH"],
  "keyPassword": "YourPassword Here"
}

PowerShell Implementation

Update your PowerShell script to define the body as a multi-valued object before converting it to JSON. This ensures the correct array structure is maintained.

# Parameters
$PVWA_URL = "https://your-pvwa-url/"
$AuthToken = "Your-Auth-Token"

# Define the body with plural 'formats' and required 'keyPassword'
$Body = @{
    formats = @("OpenSSH") 
    keyPassword = "YourPasswordHere" # Required for OpenSSH/PPK formats
} | ConvertTo-Json

# REST Call
$response = Invoke-RestMethod -Method Post `
    -Uri "$PVWA_URL/PasswordVault/API/Users/Secret/SSHKeys/Cache" `
    -Headers @{ Authorization = $AuthToken } `
    -ContentType "application/json" `
    -Body $Body

# Extract the specific key from the response value array
$openSshKey = ($response.value | Where-Object { $_.format -eq "OpenSSH" }).privateKey

Additional Considerations

  • Default Behavior: If you use the singular format parameter or omit the formats array, the API may default to providing the private key in PEM format.

  • Multiple Formats: You can request multiple formats at once by adding them to the array: "formats": ["OpenSSH", "PPK", "PEM"].

  • Access Denied: If you encounter an UnauthorizedAccessException when saving the key, ensure the execution context has write permissions to the destination folder (e.g., C:\temp\).



Actions
  • Print
  • Copy Link

    https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA1hj00000013VJCAY&lang=en_US&refURL=http%3A%2F%2Fknowledgebase.paloaltonetworks.com%2FKCSArticleDetail