How to edit values using Kobo API?

Hi @Akratos, you can do something like this in Python:

import requests
import json

URL = 'https://kf.kobotoolbox.org/api/v2/assets/admH7NjjWAEUfqnJfFbfdQ/data/bulk/'
TOKEN = 'your_secret_token'
PARAMS = {
    'fomat': 'json'
}
HEADERS = {
    'Authorization': f'Token {TOKEN}'
}

payload = {
    'submission_ids': ['1111', '1112'],
    'data': {'group_name/question_name': 'new_value'}
}

res = requests.patch(
    url=URL,
    data={'payload': json.dumps(payload)},
    params=PARAMS,
    headers=HEADERS
)

Note that you need to include the full node path to the question, so if the question name is Q1 nested in group G1, you will have the path G1/Q1.

3 Likes