【发布时间】:2016-03-02 05:44:29
【问题描述】:
我正在尝试在 PowerShell 中实现 ReST 请求。
请求 1:
$response = Invoke-RestMethod "my-custom-url" -Headers $headers -Method POST -Body $json -ContentType "application/json" -OutFile output.json -SessionVariable sv
请求 1 的响应:
{
"@type": "user",
"id": "00000703000000000010",
"orgId": "000007",
"name": "xxx@gmail.com",
}
我需要保存“id”的值并将其添加到下一个请求的标头中。我怎样才能做到这一点?
----更新--添加WriteHost $response
@{@type=user; id=00000703000000000010; orgId=000007; name=xxx; createTime=2014-08-27T12:12:21.000Z; updateTime=2016-02-27
T00:40:13.000Z; createdBy=xxx@gmail.com; updatedBy=xxx; sfUsername=ppanigrahi; firstName=Pravakar; lastName=P
anigrahi; password=********; phone=9008433201; emails=xxx@gmail.com; timezone=IST; serverUrl=http://localhost:16006/saas; spiUrl
=https://localhost:8080/; icSessionId=QpXZEkqYEflJRY7h; securityQuestion=MOTHER_MAIDEN_NAME; forceChangePassword=False; uuid=C1bL60uIQqyRaF3
nXCHFkA; roles=System.Object[]; usergroups=System.Object[]}
【问题讨论】:
-
我尝试在请求1中使用SessionVariable参数,但无法获取id的值
-
尝试使用 Cookies.GetCookies(url) 但验证 id 的值未存储在 cookie 列表中。
-
请编辑问题并添加您用于提出请求的代码。
-
添加了代码sn-p
标签: rest powershell powershell-5.0