Forum Discussion
Create / Modify the Internal Datagroup of type Internal fails using iControl REST cURL call
Hi Wackitron,
You can go through the REST Cookbooks to know when to use POST, PUT & PATCH. Also you should know, that DGL's do not have subcollections - anything that you do with the Datagroup records is like a whole replacement, so whenever you are planning to add an extra record, you should first collect all the existing ones and then add the new one along with it.
So to answer your question,
your 1st command with a POST is an add, for you to create a datagroup, you should use the below,
curl -k -u admin:admin -H "Content-Type: application/json" -X POST -d '{"name": "TEST_iRule", "partition": "Common","type": "ip", "records": [{"name": "10.10.10.10/32", "data": ""}]}' https://10.20.30.40/mgmt/tm/ltm/data-group/internal jq
your 2nd command with a PUT was right, but as the error says, for record addition/modification one would not pass the type, as the DGL is already created as type IP, so you need not give that parameter again, without that it would succeed.
curl -k -u admin:admin -H "Content-Type: application/json" -X PUT -d '{"records": [{"name": "10.10.10.10/32", "data": ""}]}' https://10.20.30.40/mgmt/tm/ltm/data-group/internal/~Common~TEST_iRule | jq
Do you have an example of how to add multiple records to a datagroup?
/jeff
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