Forum Discussion
Create / Modify the Internal Datagroup of type Internal fails using iControl REST cURL call
SID@kalamari:~$ curl -k -u admin:admin -H "Content-Type: application/json" -X POST -d '{"generation": 1, "type": "ip", "records": [{"name": "10.10.10.10/32", "data": ""}]}' https://10.20.30.40/mgmt/tm/ltm/data-group/internal/~Common~TEST_iRule | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 200 100 115 100 85 37 27 0:00:03 0:00:03 --:--:-- 39
{
"code": 400,
"message": "one or more configuration identifiers must be provided",
"errorStack": [],
"apiError": 26214401
}
SID@kalamari:~$ curl -k -u admin:admin -H "Content-Type: application/json" -X PUT -d '{"generation": 1, "type": "ip", "records": [{"name": "10.10.10.10/32", "data": ""}]}' https://10.20.30.40/mgmt/tm/ltm/data-group/internal/~Common~TEST_iRule | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 292 100 207 100 85 88 36 0:00:02 0:00:02 --:--:-- 95
{
"code": 400,
"message": "\"type\" may not be specified in the context of the \"modify\" command. \"type\" may be specified using the following commands: create, edit, list",
"errorStack": [],
"apiError": 26214401
}
Hi F5 Folks,
I am trying to create the Internal Datagroup of type: IP using POST iControl REST call, but I am getting a 400 error back. Seems like I am doing something wrong on the BODY content of the POST call.
I also tried to use the PUT call to modify the existing Datagroup, but that one failed too. Above the Request and Response of the Payload.
Help is much appreciated.
SID
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
- jba3126Cirrus
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