Edit repeat group via API

I am using the api to edit some values with

URL = 'https://[kpi-url]/api/v2/assets/{asset_uid}/data/bulk/'
TOKEN = 'value_token_xxxxx'
PARAMS = {
    'format': 'json',
    'content-type': 'application/json'
}
HEADERS = {
    'Authorization': f'Token {TOKEN}'
}

{
"payload": 
{
    "submission_ids": [ xxxxxxx], 
    "data": {
        "group_1/name_1":"Value 1",
        "group_1/name_2":"Value_2"
        }
}
}

it’s works fine for this type of questions, but it’s possible when the questions are a “repeat group”.
I try using an array but doesn’t works, something like

"data": {
        "group_question":[
                      {
                       "group_question/name_1":"Value 1",
                       "group_question/name_2":"Value_2"
                      },
                      {
                       "group_question/name_1":"Value 3",
                       "group_question/name_2":"Value_4"
                      }
                      ]        
        }

Thanks

Hi @hoffmat, unfortunately editing repeat groups through the API is not yet supported :+1:

1 Like

@Josh
I noticed the following in the v2 API documentation:

I’ve tried it and I could edit the first repeat group, but not the subsequent ones.
I mean from the example given I can edit Value 1 and Value_2 but not Value 3 or Value_4.

"data": {
        "group_question":[
                      {
                       "group_question/name_1":"Value 1",
                       "group_question/name_2":"Value_2"
                      },
                      {
                       "group_question/name_1":"Value 3",
                       "group_question/name_2":"Value_4"
                      }
                      ]        
        }

How can I edit those values?

Hi @ks_1, as I noted in my previous response, bulk edits for repeat groups is not currently supported :+1:

1 Like

I leave this message to assist future individuals who may need to make edits in repetition groups. Although I acknowledge that this may not be the ideal approach, it was the solution that worked in my case.

All the necessary information was obtained from the forum, with the crucial answer found at:

https://community.kobotoolbox.org/t/updating-records-via-the-api/4291/3

The valuable contribution was provided by “tinok.”

To perform the edit, I used the “submissions” endpoint located at:
https://kobocat.[XXXXXX]/api/v1/submissions
(The same one used for submission)

The structure should be the same as the submission, with the only modification in the fields you wish to edit (obviously). Change the instanceID (generate a UUID) and the deprecatedID (put the current instanceID here).

By following this procedure, the submission data will be replaced by the new data being transmitted.

In the provided link, there is a code example for reference. :smile:

Highly awaited feature on our side.