1
有人可以向我解釋爲什麼cUrl
(真正的cUrl)有效,但Invoke-WebRequest
不是?同一臺機器,相同的變量。對我來說,看起來他們都應該做同樣的事情,把文件上傳到jfrog Artifactory。cUrl vs Invoke-WebRequest
$headers = @{
'X-JFrog-Art-Api' = $apiKey
"Content-Type" = "application/json"
"Accept" = "application/json"
}
Invoke-WebRequest -InFile $file -Method Put -Uri "$ARTIFACTORY_HOST/third-party/test/readme.md" -Headers $headers -Verbose
此PowerShell不起作用。
curl -T readme.md "${ARTIFACTORY_HOST}/third-party/test/readme.md " \
-H "X-JFrog-Art-Api: ${apiKey}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
cUrl有效。
PowerShell的失敗,
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
At line:1 char:1
+ Invoke-WebRequest -InFile $file -Method Put -Uri "https:// ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
反斜槓是他失敗的方式,它不在PowerShell上,但在cUrl上。 你在Artifactory的日誌中看到什麼?你有沒有在Artifactory的日誌中看到什麼,或者reqeust根本沒有達到它? – Ariel
@TessellatingHeckler as Ariel通過閱讀我的帖子正確識別反斜槓是爲bash。我根本不在PowerShell中使用反引號。 我自己找到答案。 PowerShell協商TLS1.0。 –