PowerFlex 3.x The "SetPassword" REST API Call Returns "400 Bad Request"

Summary: While using Powershell to interact with the VxFlexOS/PowerFlex REST API the function "setPassword" returns a "400 bad request." However other functions work fine, such as "resetPassword." Scenario: Use custom code to set the logged in users password with "setPassword" function in the REST API, the VxFlexOS/PowerFlex Gateway returns a bad request "400" HTML code. But other functions still perform without errors. ...

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

In the logs or in the command-line something similar to the following will show that "The remote server returned an error: (400) Bad Request":

image.png

Cause

Some functions that have larger body payloads, such as "setPassword" (which requires the oldPassword object plus value and newPassword object plus value) require that the header also include the content type "application/json" for the VxFlex REST API to interpret the post call correctly.

Resolution

To resolve this issue supply the content type with the Web Request, for example the below code in PowerShell requires the "-ContentType "application/json" " added to the Invoke-WebRequest method for the post to be successful":

#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

The same thing can be done from Curl or other programming languages:

curl -v -k -X POST -H "Content-Type:application/json" ...

 

Impacted Versions

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.