【发布时间】:2020-08-13 15:46:41
【问题描述】:
很抱歉不得不在这里提出这样的问题,自学的 powershell 用户。有一个问题,我似乎无法从 GET Invoke-RestMethod 上的 JSON 返回中获得我想要的值。
我正在尝试提取 JIRA 票证数据,以便检查自定义字段是否已使用值进行更新。我曾尝试直接在响应中调用自定义字段,但是由于响应的格式设置,它只会返回数据列,因此我无法在我的代码中使用此响应。
我的代码如下:
$response = Invoke-RestMethod "https://jira-ceg.atlassian.net/rest/servicedeskapi/request/$JIRATICKET" -Method 'GET' -Headers $headers
$tester = $response.requestFieldValues
$tester
我从 JIRA 得到的回复如下:
fieldId label value
------- ----- -----
summary Summary STAFF-NEW - XXXX- NAME
customfield_10108 iTrent Information Employee ID: XXXX...
customfield_10086 Checklist Text --- ERROR - No Role Entitlement Found - Contact Service Admin
description Description A new employee has joined. Please process with the data above.
customfield_10191 New AD Address XXXX@XXXXX.com
我想捕获字段 customfield_10191 的值,该字段有时也可能为空,稍后我将在脚本中进行测试。知道我该怎么做吗?
提前致谢!
【问题讨论】:
标签: powershell rest jira-rest-api invoke-restmethod