want to insert api data intodatabase using python ,but it shows error as 'Could not process parameter: str(6875), it must be of type list/tuple/ dict'

Viewed 17

Error 'Could not process parameter: str( 11429016), it must be of type list/tuple/ dict'

totalCollectedWeightDate = RestAPI['API']['totalCollectedWeightDate']
today1 = datetime.now()
today = today1.strftime("%Y-%m-%d")
year =datetime.strftime(datetime.now() - timedelta(365), '%Y-%m-%d')
txt6 = totalCollectedWeightDate
xx6 = txt6.replace("2021-02-17",year)
yy6=xx6.replace("2022-03-17",today)

# Generate Access Token
api_url =AccessTokenAPI
headers = {"Content-Type":"application/json"}
response = requests.post(api_url, data=json.dumps(Body), 
 headers=headers2,verify=False)
response.json()
#print(response.json()["access_token"])    

# getSLAComplaintsData API Response
auth_token=response.json()["access_token"]
hed = {'Authorization': 'Bearer ' + auth_token}
totalCollectedWeightDateAPI1 =yy6
response = requests.get(totalCollectedWeightDateAPI1, headers=hed,verify=False)
r=response.content

print(r)
print(type(r))

q6 gives me the output as 11429016 which is a string but its showing an error

q6=str(json.loads(r)['SWM']['data']['dumpweight'])
print(q6)
print(type(q6))  
for totalCollectedWeightDateAPI1 in r:
 c.execute(""" UPDATE totalCollectedWeightDate22 SET dumpweight=%s """, (str(q6)))
# print(q6)
 
conn.commit()       
0 Answers
Related