# REST API add records to data group (v14.1.)

**URL:** <https://community.f5.com/t/rest-api-add-records-to-data-group-v14-1/52730>\
**Category:** Technical Forums\
**Created:** [June 5, 2019, 1:34pm UTC](https://community.f5.com/t/rest-api-add-records-to-data-group-v14-1/52730 "2019-06-05T13:34:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![raZorTT](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@raZorTT](https://community.f5.com/u/raZorTT)\
**Post date:** [June 5, 2019, 1:34pm UTC](https://community.f5.com/t/rest-api-add-records-to-data-group-v14-1/52730/1 "2019-06-05T13:34:30Z")

</div>

Hi,

I’m trying to update the records in a data group via the REST API, but when I use the following BODY in the PUT

```tcl
{
    "records": [
        {
            "name": "test",
            "data": "data"
        }
    ]
}

```

I get the following error

```tcl
{
    "code": 400,
    "message": "0107074b:3: Unable to change data group (/Common/testdg) type.  Must remove existing entries first.",
    "errorStack": [],
    "apiError": 3
}

```

Any thoughts appreciated.

Cheers,

Simon

---

<div class="post-metadata">

**Author:** ![Dario\_Garrido](https://avatars.discourse-cdn.com/v4/letter/d/d2c977/32.png) [@Dario\_Garrido](https://community.f5.com/u/Dario_Garrido)\
**Post date:** [June 5, 2019, 8:53pm UTC](https://community.f5.com/t/rest-api-add-records-to-data-group-v14-1/52730/2 "2019-06-05T20:53:15Z")

</div>

I would try this

> **[DzavyNet » How to add or remove datagroup records using iControl REST API](https://dzavy.net/software/f5/how-to-add-or-remove-datagroup-records-using-icontrol-rest-api)**

KR,

Dario.

---

<div class="post-metadata">

**Author:** ![raZorTT](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@raZorTT](https://community.f5.com/u/raZorTT)\
**Post date:** [June 6, 2019, 3:24am UTC](https://community.f5.com/t/rest-api-add-records-to-data-group-v14-1/52730/3 "2019-06-06T03:24:38Z")

</div>

Thanks, Dario

That was very useful

I managed to get the records to add using the PATCH method described in the article

To add a string record I had to use the following querystring, where test is the name of the record and stuff being the value

```tcl
/mgmt/tm/ltm/data-group/internal/~Common~testdg?options=records add { test { data stuff } }

```

That returned the expected result

```tcl
{
    "kind": "tm:ltm:data-group:internal:internalstate",
    "name": "testdg",
    "partition": "Common",
    "fullPath": "/Common/testdg",
    "generation": 184,
    "selfLink": "https://localhost/mgmt/tm/ltm/data-group/internal/~Common~testdg?options=records+add+%7B+test+%7B+data+stuff+%7D+%7D&ver=14.1.0.3",
    "type": "string",
    "records": [
        {
            "name": "test",
            "data": "stuff"
        }
    ]
}

```

Would still be interested to hear if using the PUT method is a known issue??

Cheers,

Simon

---

<div class="post-metadata">

**Author:** ![raZorTT](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@raZorTT](https://community.f5.com/u/raZorTT)\
**Post date:** [June 6, 2019, 3:50am UTC](https://community.f5.com/t/rest-api-add-records-to-data-group-v14-1/52730/4 "2019-06-06T03:50:33Z")

</div>

Looks like I should have paid more attention to the error.

I noticed it was complaining about trying to change the type, so adding the type:string to the JSON body resolved my issue.

```tcl
{
    "type":"string",
    "records": [
        {
            "name": "test",
            "data": "stuff"
        },
        {
            "name": "testing",
            "data": "more stuff"
        }
    ]
}

```

---

<div class="post-metadata">

**Author:** ![Dario\_Garrido](https://avatars.discourse-cdn.com/v4/letter/d/d2c977/32.png) [@Dario\_Garrido](https://community.f5.com/u/Dario_Garrido)\
**Post date:** [June 6, 2019, 8:28am UTC](https://community.f5.com/t/rest-api-add-records-to-data-group-v14-1/52730/5 "2019-06-06T08:28:23Z")

</div>

The behavior of PUT/PATCH was changed lastly (new releases).

The relation between tmsh and icontrol is similar to this:

GET - list/show

POST - create

PUT - update

PATCH - modify

DELETE - delete
