0
我的PowerShell腳本:爲什麼PowerShell無法發送正確的Crumb?
$Params = @{
uri = "http://${API_URL}:${API_Port}/crumbIssuer/api/json";
Method = 'Get';
Headers = @{
Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$(${API_User}):$(${API_Pass})"));
}
}
$API_Crumb = Invoke-RestMethod @Params
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Jenkins-Crumb", $API_Crumb.Crumb)
$Params = @{
uri = "http://${API_URL}:${API_Port}/job/${API_Job}/build";
Method = 'Post';
Headers = $headers;
}
Invoke-RestMethod @Params
錯誤:
No valid crumb was included in the request
你試過'UTF8.GetBytes'而不是'ASCII.GetBytes'嗎?否則像「pásswörd」這樣的密碼可能會導致異常。 –