Skip to main content
Announcements
See why Qlik was named a Leader in the 2025 Gartner® Magic Quadrant™ for Augmented Data Quality Solutions: GET THE REPORT
cancel
Showing results for 
Search instead for 
Did you mean: 
wama
Contributor

Qlik replicate AEM API returning SYS,UNRECOGNIZED_REQUEST_PATTERN,GET,/v1/servers

Hi,

I'm following AEM API documentation here

https://help.qlik.com/en-US/enterprise-manager/May2021/Content/EnterpriseManager/EnterpriseManager_A...

and able to login and getting APISessionID, but when APISessionID returned is passed to other APIs such as 

/api/v1/servers it's returning application-status as 500 and error as "SYS-E-UNRECREQ, Unrecognized request pattern 'GET: /v1/servers'."

Can someone help me, what's missing?

 

Labels (2)
1 Reply
TomaszRomanowski
Partner - Contributor II

Hi,

 

I had the same error in powershell script that should stop task. 

Problem is with codding url parameters.

below my full working script:

# Configuration
$qlik_ent_man_url = "https://XXX.XXX.XXX.XXX"
$credentials_login = 'my_login_name'
$credentials_password = 'my_login_password'
$credentials_domain = 'my_hostname_or_domain'
$server_name = "my_Qlik_Replicate_name_in_QEM"  
$task_name = "my_task_name"  
$stop_timeout = 600
 
 
# Login - Retrieve apisessionid
$credentials_enc = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("${credentials_domain}\${credentials_login}:${credentials_password}"))
$session = new-object microsoft.powershell.commands.webrequestsession
$response = Invoke-WebRequest -Uri "$qlik_ent_man_url/attunityenterprisemanager/api/v1/login" -Headers @{ "Authorization" = "Basic $credentials_enc" } -WebSession $Session -Method POST -SkipCertificateCheck
$session_id = $response.Headers["EnterpriseManager.APISessionID"]
 
# Check if session ID was retrieved successfully
if (-not $session_id) {
    Write-Host "Login failed! Could not retrieve 'apisessionid'." -ForegroundColor Red
    exit 1
  
Write-Host "Successfully logged in. Stopping task..." -ForegroundColor Green
 
# Stop task
$headers = @{
    "EnterpriseManager.APISessionID" = "$session_id"
}
 
# function quote_param to encode URL params
function Quote-Param {
    param([string]$param)
    return [System.Net.WebUtility]::UrlEncode($param)
    }
 
$task_url = "$qlik_ent_man_url/attunityenterprisemanager/api/v1/servers/" + (Quote-Param $server_name) + "/tasks/" + (Quote-Param $task_name) + "?action=stop&timeout=" + (Quote-Param $stop_timeout) + ""
try {
$task_stop = Invoke-WebRequest  -Uri $task_url -Headers $headers -WebSession $Session -Method POST -SkipCertificateCheck
    }
catch {
    Write-Host "Server responsed with error: $_"  -ForegroundColor RED
exit 1
}
 
$task_info = $task_stop.Content | ConvertFrom-Json
 
Write-Host "[ Task Stopping:  $($task_info.state) ($($task_info.error_message)) ]"  -ForegroundColor GREEN
 
# Logout session
$logout_details = Invoke-WebRequest -Uri "$qlik_ent_man_url/attunityenterprisemanager/api/v1/logout" -Headers @{ "EnterpriseManager.APISessionID" = "$session_id" } -Method POST -SkipCertificateCheck
Write-Host "Logged out successfully." -ForegroundColor Green