【发布时间】:2021-03-29 18:37:31
【问题描述】:
有没有办法直接从 PowerBI 的 service now API 获取数据?我有以下 powershell 代码
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$body = @{
env = "https://companyqa.service-now.com/"
username = "username"
password = "password"
client_id = "client_id"
client_secret = "client_secret"
grant_type = "password"
}
$gettoken = Invoke-RestMethod -Method POST -Uri "$($body.env)oauth_token.do?grant_type=password&client_id=$($body.client_id)&client_secret=$($body.client_secret)&username=$($body.username)&password=$($body.password)" -ContentType 'application/x-www-form-urlencoded'
$token = $gettoken.access_token
echo $token
$headers = @{“authorization” = “Bearer $token”}
$Type = "application/json"
$getincidents = Invoke-RestMethod -Method GET -Uri "$($body.env)/api/now/v2/table/incident?sysparm_query=number=NUM111111" -Headers $headers -ContentType $Type
$getincidents.result
我正在寻找在 PowerBI 中复制上述内容并直接获取数据的示例。这可能吗?
【问题讨论】:
标签: powershell api rest powerbi servicenow