Home Analyst Portal

Knowledge Base API

Raffael_JenzerRaffael_Jenzer Customer IT Monkey ✭
Hi

We're trying to get KB articles with API calls.

Here is our Powershell-Script:
---
param ($Data1,
    $Data2,
    $Data3,
    $Data4,
    $Data5,
    $Data6,
    $Data7)

#enter your portal URL here
$site = "https://portal.xxxxx.xx"

$credentials = @{
    UserName = 'DOMAIN\username'
    Password = 'password'
    LanguageCode = 'ENU'
}
$jsonCredentials = $credentials | ConvertTo-Json

#first retrieve your access token
$url = $site + "/api/V3/Authorization/GetToken"

$apiKey = try { Invoke-RestMethod $url -Method POST -Body $jsonCredentials -ContentType 'application/json' } catch { $_.Exception.Response }

$authVal = "Token " + $apiKey

$Data5 = 76

$url1 = $site + "/api/V3/KnowledgeBase/GetKnowledgeArticle?articleId={$Data5}"
#$url1 = $site + "/api/V3/User/GetUserList" --> diese Abfrage funktioniert.


$response1 = try { Invoke-RestMethod $url1 -Method GET -ContentType 'application/json' -Headers @{ "AUTHORIZATION" = $authVal } }
    catch { $_.Exception.Response }
---

We're not able to get a result with this script. Could someone help us?

Thanks,
Raffael

Best Answer

Answers

  • Raffael_JenzerRaffael_Jenzer Customer IT Monkey ✭
    Hi Geoff,

    Based on help from Cireson Support (this was one step to the solution) and based on your help, my colleague was able to resolve the problem.

    This is the working Powershell-Script:
    ---
    param ($Data1,
        $Data2,
        $Data3,
        $Data4,
        $Data5,
        $Data6,
        $Data7)

    #enter your portal URL here
    $site = "https://portal.xxxxx.xx"

    $credentials = @{
        UserName = 'DOMAIN\username'
        Password = 'password'
        LanguageCode = 'ENU'
    }
    $jsonCredentials = $credentials | ConvertTo-Json

    #first retrieve your access token
    $url = $site + "/api/V3/Authorization/GetToken"

    $apiKey = try { Invoke-RestMethod $url -Method POST -Body $jsonCredentials -ContentType 'application/json' } catch { $_.Exception.Response }

    $authVal = "Token " + $apiKey

    $Data5 =1

    $url1 = $site + "/api/V3/KnowledgeBase/GetHTMLKnowledgeArticle?knowledgeArticleId=$Data5"
    #$url1 = $site + "/api/V3/User/GetUserList"


    $response1 = try { Invoke-RestMethod $url1 -Method GET -ContentType 'application/json' -Headers @{ "AUTHORIZATION" = $authVal } }
        catch { $_.Exception.Response }

    $Data1 = "test"
    ---

    Thanks for your help!

    Take care,
    Raffael
  • ShampShamp Member IT Monkey ✭
    I am not able to get this working. Is it because we are set up to use Azure App proxy
Sign In or Register to comment.