【问题标题】:Is there a way to pass credentials to SCOM rest api through postman ? I am getting 401 error有没有办法通过邮递员将凭据传递给 SCOM rest api?我收到 401 错误
【发布时间】:2020-11-05 05:09:47
【问题描述】:

在将 post rest api 调用发送到 scom 服务器时,我无法确定正文中的 json 正文下应该包含什么内容。我尝试了以下方法。

{
    "credentials":"<base64 coded text of credential>"
    
}

这是标题和正文

还有错误

这是我尝试更改为 postmain 请求的 powershell 脚本 rest api 请求

 $server="servername"
 
# authentication part
 
$scomHeaders = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$scomHeaders.Add('Content-Type','application/json; charset=utf-8')
 
$bodyraw = "Windows"
$Bytes = [System.Text.Encoding]::UTF8.GetBytes($bodyraw)
$EncodedText =[Convert]::ToBase64String($Bytes)
$jsonbody = $EncodedText | ConvertTo-Json
 
$uri = "http:// $server/OperationsManager/authenticate"

$username = "username.com"
$password = ConvertTo-SecureString "paswword" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList ($username, $password)

$Request = Invoke-WebRequest `
    -Method POST `
    -Uri $uri `
    -Headers $scomHeaders `
    -body $jsonbody `
    -Credential $cred `
    -SessionVariable 'websession'
 

我还尝试使用I want to fetch the SCOM alerts data. But I keep getting the error 401. I am passing the credentials right 帖子的帮助。还是想不通。

【问题讨论】:

    标签: scom


    【解决方案1】:

    SCOM 支持将基本身份验证作为标头的一部分。这是一篇关于它的文章: https://mevansit.blogspot.com/2017/03/scom-web-availability-monitoring-with.html

    【讨论】:

    猜你喜欢
    • 2020-09-05
    • 1970-01-01
    • 1970-01-01
    • 2019-08-26
    • 1970-01-01
    • 2022-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多