我試圖在PowerShell中實現ReST請求。如何在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": "[email protected]",
}
我需要保存 「ID」 的值&它添加到下一個請求的報頭。我怎樣才能做到這一點?
----更新 - 添加WriteHost $響應
@{@type=user; id=00000703000000000010; orgId=000007; name=xxx; createTime=2014-08-27T12:12:21.000Z; updateTime=2016-02-27
T00:40:13.000Z; [email protected]; updatedBy=xxx; sfUsername=ppanigrahi; firstName=Pravakar; lastName=P
anigrahi; password=********; phone=9008433201; [email protected]; 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爲 – live2learn
的值與Cookies.GetCookies(url)一起嘗試,但驗證了id的值未存儲在cookie列表中。 – live2learn
請編輯問題並添加您用於提出請求的代碼。 – Cobster