PowerShell和ServiceNow REST API Dot-Walking无法正常工作

时间:2016-01-06 00:59:15

标签: powershell servicenow

我可以在正文中指定一个值(例如:" sys_updated_by" =" JSmith")并成功返回该特定记录

$URL = "https://domain.service-now.com/api/now/v1/table/sc_item_option_mtom" 
$headers = @{"AUTHORIZATION"="Basic 12345678900987654321"} 
$Body = @{ 
"sysparm_limit"="1" 
"sys_updated_by"="JSmith" 
} 
(Invoke-RestMethod -Headers $headers -Method Get -Uri $URL -Body $Body).result

request_item   : @{link=https://domain.service-now.com/api/now/v1/table/sc_req_item/cc6f59d4c0779100925cad13165a7325; value=cc6f59d4c0779100925cad13165a7325}
sc_item_option : @{link=https://domain.service-now.com/api/now/v1/table/sc_item_option/d37c591cc0779100925cad13165a7397; value=d37c591cc0779100925cad13165a7397}
sys_updated_by : JSmith
sys_tags       : 
sys_updated_on : 2014-03-27 16:26:24
sys_id         : 006f555cc0779100925cad13165a7377
sys_mod_count  : 0
sys_created_on : 2014-03-27 16:26:24
sys_created_by : JSmith

当我使用request_item.value(或request_item.link,我还没有发现任何有效的东西)点走时,我无法返回正确的记录。我使用了从上面返回的值(cc6f59d4c0779100925cad13165a7325),但查询似乎忽略了整行" request_item.value" =" cc6f59d4c0779100925cad13165a7325"并返回表中的第一条记录

$URL = "https://domain.service-now.com/api/now/v1/table/sc_item_option_mtom"
$headers = @{"AUTHORIZATION"="Basic 12345678900987654321"} 
$Body = @{ 
"sysparm_limit"="1"     
"request_item.value"="cc6f59d4c0779100925cad13165a7325" 
} 
(Invoke-RestMethod -Headers $headers -Method Get -Uri $URL -Body $Body).result

request_item   : @{link=https://domain.service-now.com/api/now/v1/table/sc_req_item/00020bbc6892d900925cda2e3d5bf84a; value=00020bbc6892d900925cda2e3d5bf84a}
sc_item_option : @{link=https://domain.service-now.com/api/now/v1/table/sc_item_option/f2f14bbc6892d900925cda2e3d5bf8d1; value=f2f14bbc6892d900925cda2e3d5bf8d1}
sys_updated_by : CHOLMES
sys_tags       : 
sys_updated_on : 2014-01-13 23:20:06
sys_id         : 00020bbc6892d900925cda2e3d5bf84c
sys_mod_count  : 0
sys_created_on : 2014-01-13 23:20:06
sys_created_by : CHOLMES

1 个答案:

答案 0 :(得分:0)

这似乎是这样做的:“https:// domain.service-now.com/sc_item_option_mtom.do?CSV&sysparm_query=request_item=sy s_id