Jump to content

KSC 11 OpenApi


Go to solution Solved by 0xcffaedfe,

Recommended Posts

Скрипт на PowerShell 5.1

$ksc_server = "https://server:13299"
$url = $ksc_server + "/api/v1.0/login"
$user = 'domain\user'
$password = '******'
$user = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($user))
$password = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($password))

$parameters = @{
    Uri         = $url
    Headers     = @{ 'Authorization' = 'KSCBasic user=$user, pass=$password' }
    Method      = 'POST'
    ContentType = 'application/json'
}

Invoke-RestMethod @parameters

Выдает ошибку : 

Invoke-RestMethod : Authentication header is invalid - не могу понять, в чем проблема ?

 

Link to comment
Share on other sites

  • 4 weeks later...
  • Solution

Скрипт на PowerShell 5.1

$ksc_server = "https://server:13299"
$url = $ksc_server + "/api/v1.0/login"
$user = 'domain\user'
$password = '******'
$user = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($user))
$password = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($password))

$parameters = @{
    Uri         = $url
    Headers     = @{ 'Authorization' = 'KSCBasic user=$user, pass=$password' }
    Method      = 'POST'
    ContentType = 'application/json'
}

Invoke-RestMethod @parameters

Выдает ошибку : 

Invoke-RestMethod : Authentication header is invalid - не могу понять, в чем проблема ?

 

Проблема в неправильном хедере логин и пасс передаются в кавычках:

    Headers     = @{ 'Authorization' = "KSCBasic user=`"$user`", pass=`"$password`"" }

 

ну и на всякий скинуть проверку cерта: Invoke-RestMethod @parameters -SkipCertificateCheck 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...