Forum Discussion
Create iRule REST error: Found invalid JSON body in the request
- Mar 30, 2022
I posted your curl command in as is (except for the BIG-IP hostname swap) and it worked just fine:
jrahm % curl -sku admin:admin -H "Content-Type: application/json" -X POST https://ltm3.test.local/mgmt/tm/ltm/rule -d '{"name":"f5RESTSampleRule", "apiAnonymous":"when CLIENT_ACCEPTED {\n node 172.28.0.41 \n}" }' {"kind":"tm:ltm:rule:rulestate","name":"f5RESTSampleRule","partition":"Common","fullPath":"/Common/f5RESTSampleRule","generation":1585,"selfLink":"https://localhost/mgmt/tm/ltm/rule/~Common~f5RESTSampleRule?ver=15.1.2.1","apiAnonymous":"when CLIENT_ACCEPTED {\n node 172.28.0.41 \n}"}
Could be mangled smartquotes or something? Try copying from vs code or vi and not any text editor that "helps" with formatting. 🙂
I posted your curl command in as is (except for the BIG-IP hostname swap) and it worked just fine:
jrahm % curl -sku admin:admin -H "Content-Type: application/json" -X POST https://ltm3.test.local/mgmt/tm/ltm/rule -d '{"name":"f5RESTSampleRule", "apiAnonymous":"when CLIENT_ACCEPTED {\n node 172.28.0.41 \n}" }'
{"kind":"tm:ltm:rule:rulestate","name":"f5RESTSampleRule","partition":"Common","fullPath":"/Common/f5RESTSampleRule","generation":1585,"selfLink":"https://localhost/mgmt/tm/ltm/rule/~Common~f5RESTSampleRule?ver=15.1.2.1","apiAnonymous":"when CLIENT_ACCEPTED {\n node 172.28.0.41 \n}"}
Could be mangled smartquotes or something? Try copying from vs code or vi and not any text editor that "helps" with formatting. 🙂
Must be something weird with me doing it through Windows command line. I tried a few different code editors as well as retyping the command manually to ensure I was not copy-pasting a bad character. I still kept getting the same error.
Your post was helpful though, that told me I was at least passing the correct info. I ended up writing a small c# program that would create the iRule for me using the REST API and it works great.
Thank you!
- JRahmMar 31, 2022Admin
been a while since I danced with C#...nice!
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