...it's connecting to the Emsisoft API (https://api.emsisoft.com/) to create a workspace, but I need help understanding the error.
# Define your API endpoint URL
$apiUrl = "https://api.emsisoft.com/v1/workspaces"
# Set your API key
$apiKey = "XXXXXXXXXXXXXXXXXXXXXXX"
# Create headers with API-KEY and ACCEPT
$headers = @{
"API-KEY" = $apiKey
"ACCEPT" = "application/json"
"Content-Type" = "application/json"
}
$body = @{
"name"="XXXXXXXXXXXXXXXXXXXXXXX"
"securityManagementLevel"="LocalAndRemote"
"licenseKey"="ABC-XXX-XXX-123"
}
# Make the API request
try {
$response = Invoke-RestMethod -Uri $apiUrl -Headers $headers -Method Post -Body $body -ContentType 'application/json'
# Process the response (e.g., parse JSON, handle data)
# ...
Write-Host "API request successful!"
} catch {
Write-Host "Error: $_"
}
and the error
Error: {
"error": {
"code": "ValidationFailed",
"message": "Unexpected character encountered while parsing value: s. Path '', line 0, position 0.",
"target": ""
}
}
Tried changing " to '.
From your link, I see that the request requires passing the following fields:
However, you pass: