Forum Discussion
How to Get FailOver Status via iControl REST?
Hi Guys,
I´m playing with some REST calls, and I would like to get a specific information from a GET request. In the example:
GET , I got the following response:
{
"kind": "tm:cm:failover-status:failover-statusstats",
"selfLink": "[https://localhost/mgmt/tm/cm/failover-status?ver=12.1.2"](https://localhost/mgmt/tm/cm/failover-status?ver=12.1.2);,
"entries": {
"[https://localhost/mgmt/tm/cm/failover-status/0"](https://localhost/mgmt/tm/cm/failover-status/0);: {
"nestedStats": {
"entries": {
"color": {
"description": "green"
},
"[https://localhost/mgmt/tm/cm/failoverStatus/0/details"](https://localhost/mgmt/tm/cm/failoverStatus/0/details);: {
"nestedStats": {
"entries": {
"[https://localhost/mgmt/tm/cm/failoverStatus/0/details/0"](https://localhost/mgmt/tm/cm/failoverStatus/0/details/0);: {
"nestedStats": {
"entries": {
"details": {
"description": "active for /Common/traffic-group-1"
}
}
}
}
}
}
},
"status": {
"description": "ACTIVE"
},
"summary": {
"description": "1/1 active"
}
}
}
}
}
}
Is it possible to use query parameters to get a specific response? In the example above, I would only like to receive the appliance status (description": "ACTIVE"). I was trying to work with $filter and $select parameter but no success.
Plus, if someone could give me one example of each parameter, it would be great.
- Arnaud_LemaireEmployee
you can use this uri : /mgmt/tm/cm/failover-status?$select=status
but you will still have a nested response.
{ "entries": { "https://localhost/mgmt/tm/cm/failover-status/0": { "nestedStats": { "entries": { "status": { "description": "ACTIVE" } } } } } }
To answer your follow-up question:
This is just how the rest API works. You have to do some client side manipulation to get the actual data.
Here's an example in Powershell:
$Response = (Invoke-WebRequest -Method "GET" -Headers $headers -Uri "https://mydevice.j.local/mgmt/tm/cm/failover-status?`$select=status").content | ConvertFrom-Json $content.entries.'https://localhost/mgmt/tm/cm/failover-status/0'.nestedStats.entries.status.description
/Patrik
- ChimyNimbostratus
Hello Patric_Jonsson
I use your example in powershell but and error appear
I tried to fix, but there are something that is missed.
Could you re-check the code?
I think that point of view to perform the task to know if the device is active/standby is pretty cool 🙂
PS C:\Windows\system32> $Response = (Invoke-WebRequest -Method "GET" -Headers $headers -Uri "https://$f5/mgmt/tm/cm/failover-status?`$select=status").content | ConvertFrom-Json $content.entries.'https://localhost/mgmt/tm/cm/failover-status/0'.nestedStats.entries.status.descriptionConvertFrom-Json : Cannot bind argument to parameter 'InputObject' because it is null.
At line:1 char:154
+ ... rtFrom-Json $content.entries.'https://localhost/mgmt/tm/cm/failover-s ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [ConvertFrom-Json], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertFromJsonCommand- ChimyNimbostratus
finally I did !!
$response = (Invoke-WebRequest -Method "GET" -Headers $headers -Uri "https://$f5/mgmt/tm/cm/failover-status?`$select=status").content
$qestate = ($response | ConvertFrom-Json).entries.'https://localhost/mgmt/tm/cm/failover-status/0'.nestedStats.entries.status.description
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com