Forum Discussion
jjohnson
Nimbostratus
Jul 02, 2020iControl REST API Policy Rules
Having some trouble getting rules added to an LTM policy using iControl REST API and PowerShell. Currently I am able to get the policy into Draft status, and I can add a rule... but I am getting stuc...
jjohnson
Nimbostratus
Jul 02, 2020Alright... got it working!! Thank you for the assistance. I may be reaching out again before this is done 🙂
Here's what I did to get it working...
$ActionsBody = @"
{
"actions": [
{
"name": "0",
"request": true,
"forward": true,
"pool": "/Common/pool_test"
}
],
"conditions": [
{
"name":"0",
"request": true,
"httpHost": true,
"equals": true,
"values": [
"www.mydomain.net"
]
}
]
}
"@
Invoke-RestMethod -Uri https://$url/mgmt/tm/ltm/policy/~Common~Drafts~$Policy/rules/Testing -Method PUT -Headers $Header -Body $ActionsBody -ContentType 'application/json'cjunior
Nacreous
Jul 02, 2020Yes, now I test it right.
We forgot that array collections: 😕
$ActionsBody = @{
actions = @( @{
name = "0"
request = $true
forward = $true
pool = "/Common/pool_teste"
} )
conditions = @( @{
name = "0"
request = $true
httpHost = $true
equals = $true
values = @("www.mydomain.net")
} )
}
Invoke-RestMethod -Uri https://$url/mgmt/tm/ltm/policy/~Common~Drafts~$Policy/rules/Testing -Method PUT -Headers $Header -Body (ConvertTo-Json $ActionsBody -Depth 3) -ContentType 'application/json'Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
