我正在尝试在 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[]}