if r2.status_code == 200 and r2.headers.get('Content-Type', '').startswith('application/json'):
data = r2.json()
else:
print("Failed to get valid JSON response.")
print("Status Code:", r2.status_code)
print("Response:", r2.text)
return # Or handle the error accordingly
data = r2.json()
else:
print("Failed to get valid JSON response.")
print("Status Code:", r2.status_code)
print("Response:", r2.text)
return # Or handle the error accordingly