def get_responses_from_kobo(auth, form_name):
    '\n    Request kobo api to collect all the information related to a form.\n\n    Also, retrieve the form responses for parsing and filtering.\n    '
    form_url = request.args.get('koboUrl')
    if (form_url is None):
        raise BadRequest('Missing parameter koboUrl')
    resp = requests.get(form_url, auth=auth)
    resp.raise_for_status()
    kobo_user_metadata = resp.json()
    forms_iterator = (d for d in kobo_user_metadata.get('results') if (d.get('name') == form_name))
    form_metadata = next(forms_iterator, None)
    if (form_metadata is None):
        raise NotFound('Form not found')
    resp = requests.get(form_metadata.get('url'), auth=auth)
    resp.raise_for_status()
    form_metadata = resp.json()
    form_labels = {f.get('$autoname'): f.get('type') for f in form_metadata.get('content').get('survey')}
    resp = requests.get(form_metadata.get('data'), auth=auth)
    resp.raise_for_status()
    form_responses = resp.json().get('results')
    return (form_responses, form_labels)
Request kobo api to collect all the information related to a form.

Also, retrieve the form responses for parsing and filtering.
def get_responses_from_kobo(auth, form_name):
    '\n    Request kobo api to collect all the information related to a form.\n\n    Also, retrieve the form responses for parsing and filtering.\n    '
    form_url = request.args.get('koboUrl')
    if (form_url is None):
        raise BadRequest('Missing parameter koboUrl')
    resp = requests.get(form_url, auth=auth)
    resp.raise_for_status()
    kobo_user_metadata = resp.json()
    forms_iterator = (d for d in kobo_user_metadata.get('results') if (d.get('name') == form_name))
    form_metadata = next(forms_iterator, None)
    if (form_metadata is None):
        raise NotFound('Form not found')
    resp = requests.get(form_metadata.get('url'), auth=auth)
    resp.raise_for_status()
    form_metadata = resp.json()
    form_labels = {f.get('$autoname'): f.get('type') for f in form_metadata.get('content').get('survey')}
    resp = requests.get(form_metadata.get('data'), auth=auth)
    resp.raise_for_status()
    form_responses = resp.json().get('results')
    return (form_responses, form_labels)