PowerFlex 3.x 「SetPassword」REST API 呼叫傳回「400 Bad Request」
Summary: 使用 Powershell 與 VxFlexOS/PowerFlex REST API 互動時,函數「setPassword」會傳回「400 bad request」。不過,其他功能也能正常運作,例如「resetPassword」。 案例: 使用自訂代碼以 REST API 中的「setPassword」功能設定登入的使用者密碼時,VxFlexOS/PowerFlex Gateway 會傳回錯誤要求「400」HTML 代碼。但其他功能仍然執行沒有錯誤。 ...
This article applies to
This article does not apply to
This article is not tied to any specific product.
Not all product versions are identified in this article.
Symptoms
在記錄或命令列中,類似以下內容會顯示「遠端伺服器傳回錯誤:(400) 錯誤要求“:


Cause
某些具有較大主體有效負載的函數,例如「setPassword」(需要 oldPassword 物件加值和 newPassword 物件加值),要求標頭也包含內容類型「application/json」,以便 VxFlex REST API 能正確解譯後調用。
Resolution
若要解決此問題,請向內容類型提供 Web 請求,例如,PowerShell 中的以下代碼需要將「-ContentType “application/json”添加到 Invoke-WebRequest 方法中,才能成功發佈:
#format the user/pw hash in BASE64 to get it parsed by REST
$head = @{"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("admin:Scaleio1234"))}
$head
#get token for authorization.
$r = Invoke-WebRequest -Uri https://192.168.199.76/api/login -Method Get -Headers $head -UseBasicParsing
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(":" + $r.content.replace('"','')))
$header = @{'Authorization' = "Basic $token"}
$payload2 = @{
oldPassword = 'Scaleio1234'
newPassword = 'Scaleio123'
}
$body2 = Convertto-JSON -InputObject $payload2
Invoke-WebRequest -Uri https://192.168.199.76/api/instances/User/action/setPassword -Headers $header -Method Post -ContentType "application/json" -Body $body2
從 Curl 或其他程式設計語言中也可以做同樣的事情:
curl -v -k -X POST -H "Content-Type:application/json" ...
受影響的版本
PowerFlex 3.x
Affected Products
PowerFlex SoftwareProducts
PowerFlex rack, PowerFlex Appliance, PowerFlex custom nodeArticle Properties
Article Number: 000194607
Article Type: Solution
Last Modified: 14 Apr 2025
Version: 2
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.