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, 2020This is what I get now... Everything seems correct...
PS > $jsonBody = $ActionsBody | ConvertTo-Json
PS > $jsonBody
{
"conditions": {
"name": "0",
"request": true,
"httpHost": true,
"equals": true,
"values": "www.mydomain.net"
}
}
PS > Invoke-RestMethod -Uri https://$url/mgmt/tm/ltm/policy/~Common~Drafts~$Policy/rules/Testing -Method PUT -Headers $Header -Body $jsonBody -ContentType 'application/json'
Invoke-RestMethod : {"code":400,"message":"Found unexpected json string at configuration item /ltm/policy/~Common~Drafts~TEST_POLICY_AUTOMATION/rules/Testing/conditions/name. The json string is
- cjuniorJul 02, 2020
Nacreous
This way looks good for me:
$ActionsBody = [ordered]@{ 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 (ConvertTo-Json $ActionsBody) -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
