Aruba & ProVision-based
1754014 Members
5133 Online
108811 Solutions
New Discussion

REST call fails from powershell on 2920 (J9729A) but succeed on 3810M

 
SOLVED
Go to solution
mhult
Occasional Contributor

REST call fails from powershell on 2920 (J9729A) but succeed on 3810M

I'm doing some REST calls on our HPE Aruba switches but I run into a weird error. I've setup calls to our 3810M switches (KB_16_10_0011) and they work fine. On our 2920 switches (WB_16_10_0010) I can only call the REST api's from Postman but all calls from powershell fail. On the 3810M's I can both call from Postman and powershell, both http and ssl.

Here is what happens in Postman on de 2920 (I can't upload pictures):

POST: http://192.168.141.250/rest/v7/login-sessions

BODY: {"userName":"Admin""password":"###########"}

RESULT: 

{
    "payloadSize"16384,
    "uri""/login-sessions",
    "cookie""sessionId=WnWeHeoigJ4FMsDmf6CvV4ZJLcWbjmjhLqfTwXyzLTw9QMLmB5a3eOjlaSGEZEM"
}

This all works fine, I get a session ID.

In Postman I can click on code and I can generate a powershell script:

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type""application/json")

$body = "{`"userName`":`"Admin`", `"password`":`"###########`"}"

$response = Invoke-RestMethod 'https://192.168.141.250/rest/v7/login-sessions' -Method 'POST' -Headers $headers -Body $body 
$response | ConvertTo-Json
 
If I run this script to the 2920 I get an error:
Invoke-RestMethod : The underlying connection was closed: The connection was closed unexpectedly.
At line:1 char:1
+ Invoke-RestMethod 'https://192.168.141.250/rest/v7/login-sessions' 
 
However this same piece of code works fine to our 3810M switches. I've tested with adding cookies to the request but this doesn't make a difference. 
I've wireshark'd the requests from Postman and Powershell and they are identical except for 1 thing; the request from Postman is always send in 1 TCP segment and the request from powershell is always send in 2 TCP segments. However you might think that switches can handle TCP segments
 
Anybody got a clue? For now it seems most likely to me there is some bug in de 2920 switches...
1 REPLY 1
mhult
Occasional Contributor
Solution

Re: REST call fails from powershell on 2920 (J9729A) but succeed on 3810M

Ok so I tried Powershell 7.10 and this works fine. I don't understand why Powershell 5 is failing, this is rather basic stuff...