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) Bad Request":

image.png

Cause

「setPassword」(oldPasswordオブジェクトと値、newPasswordオブジェクトと値が必要)など、本文のペイロードが大きい一部の関数では、VxFlex REST APIがpost呼び出しを正しく解釈するために、ヘッダーにコンテンツ タイプ「application/json」も含める必要があります。

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 Software

Products

PowerFlex rack, PowerFlex Appliance, PowerFlex custom node
Article 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.