Hi all,
I’m struggling automating a change on the Netscaler using REST API. When I use Invoke-RestMethod to do “PUT” operation I get a strange error: Invoke-RestMethod : { “errorcode”: 1026, “message”: “Not logged in”, “severity”: “ERROR” }
This operation with the same body and using the same account executed from Postman works OK, so it’s not an issue with missing rights. Here’s the command that returns this error:
Invoke-RestMethod -Credential $NSCreds -Method PUT -Uri “http://HOST/nitro/v1/config/sslvserver/$vipname” -ContentType “application/json” -Body $DHDisableBody
Anyone knows what might be causing this? Is it necessary to provide credentials inside the body maybe? I tried everything and nothing works.
That would be my guess as well. The only way to know would be to consult the docs for the API, though. It’s not a PowerShell thing; you’re just not passing something it wants.
Thank you for your help. Turned out I had to switch from basic to oauth authentication.
I had to run “http://$netscalerIP/nitro/v1/config/login” first to get the websession. Now all the other queries instead of using -credential use -WebSession $loginsession parameter and it’s all happy.