Fetch data from Open Data Kit using an api with basic authentication

Dear team,
I am trying to fetch data using an api from Kobocollect ODK but with no avail because its loading forever, that tells me that my code is a problem. Can anyone help me out

import streamlit as st
import pandas as pd
import request

#  fetch tables through HTTP GET and authenticating with HTTP Basic Auth (admin:password)
res = request.get("https://kc.humanitarianresponse.info/api/v1/data/123456.csv", auth=("admin","password"))
df = pd.read_csv(res)

If you didnt have authentication you could pass the URL directly into the pd.read_csv, for this instance I think this should work…

from io import StringIO

res = requests.get(URL, auth=(user, pass))
df = pd.read_csv(StringIO(res.text))

@ash2shukla i am getting below error even if i change .txt to csv


you have probably mis-typed res.text as res.txt

Hello @ash2shukla,
I just realized the typo, but all the same i am getting the below error

Are you doing this,


or are you skipping StringIO
it looks like you are passing res.text directly to read_csv

It is true I didn’t include StringIO, Thanks alot I worked perfectly fine