iControl REST 101 – Creating Objects
If you’ve been following along so far you’ve gotten an idea about what iControl REST is all about, seen how to get up and running so you can send commands via cURL to the API, parsed some responses, ...
Published Feb 20, 2014
Version 1.0Colin_Walker_12
Historic F5 Account
Joined May 12, 2005
Colin_Walker_12
Historic F5 Account
Joined May 12, 2005
Riley_Schuit_82
Nov 06, 2014Historic F5 Account
A little late but, Tewfik: surround your message body with single quotes. Example:
Fails: $ curl -s -k -u admin:admin -H "Accept: application/json" -H "Content-type: application/json" -X POST -d "{"name":"cw_test2","address":"10.10.10.4/8","vlan":"internal2"}" https://172.24.130.88/mgmt/tm/net/self
Output:
{"code":400,"message":"Found invalid JSON body in the request.","errorStack":[]}
Succeeds: $ curl -s -k -u admin:admin -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"cw_test4","address":"10.10.10.5/8","vlan":"internal2"}' https://172.24.130.88/mgmt/tm/net/self
Output:
{"kind":"tm:net:self:selfstate","name":"cw_test4","fullPath":"cw_test4","generation":1106,"selfLink":"https://localhost/mgmt/tm/net/self/cw_test4?ver=11.5.0","address":"10.10.10.5/8","floating":"disabled","inheritedTrafficGroup":"false","trafficGroup":"/Common/traffic-group-local-only","unit":0,"vlan":"/Common/internal2"}