PowerFlex 3.x Wywołanie interfejsu API REST "SetPassword" zwraca wartość "400 nieprawidłowe żądanie"
Summary: Podczas korzystania z programu PowerShell do interakcji z interfejsem API REST VxFlexOS/PowerFlex funkcja "setPassword" zwraca żądanie "400 nieprawidłowe". Jednak inne funkcje, takie jak "resetPassword", działają poprawnie. Scenariusz: Użyj niestandardowego kodu, aby ustawić hasło zalogowanych użytkowników za pomocą funkcji "setPassword" w interfejsie API REST, bramka VxFlexOS/PowerFlex zwraca nieprawidłowy kod HTML "400". Ale inne funkcje nadal działają bezbłędnie. ...
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
W dziennikach lub w wierszu poleceń coś podobnego do poniższego pokaże, że "Serwer zdalny zwrócił błąd: (400) Nieprawidłowe żądanie":


Cause
Niektóre funkcje, które mają większe ładunki treści, takie jak "setPassword" (który wymaga wartości plus obiektu oldPassword i obiektu newPassword plus wartość), wymagają, aby nagłówek zawierał również typ zawartości "application/json" dla interfejsu API REST VxFlex w celu poprawnego zinterpretowania wywołania post.
Resolution
Aby rozwiązać ten problem, podaj typ zawartości z żądaniem internetowym, na przykład poniższy kod w programie PowerShell wymaga "-ContentType "application/json" " dodanego do metody Invoke-WebRequest, aby post zakończył się pomyślnie":
#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
To samo można zrobić z Curl lub innych języków programowania:
curl -v -k -X POST -H "Content-Type:application/json" ...
Wersje, których dotyczy problem
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.