[Question]: Can the interface in this document still be used? docs/references/ragflow_api.md
Describe your problem
I want to use the interface in this document, but I find that it seems unusable This is the Python code I use
import requests
def get_datasets(api_key, base_url):
url = f"{base_url}/dataset"
headers = {
"Authorization": f"Bearer {api_key}"
}
response = requests.get(url, headers=headers)
print(f"Response status code: {response.status_code}")
print(f"Response content: {response.text}") # Print the response content to see what's being returned
if response.status_code == 200:
try:
data = response.json()
if data.get('code') == 0:
print("Datasets:")
for dataset in data['data']:
print(f"- {dataset['name']} (ID: {dataset['id']})")
else:
print(f"Error: {data.get('message')}")
except requests.exceptions.JSONDecodeError:
print("Failed to decode JSON response.")
else:
print(f"HTTP Error: {response.status_code}")
if __name__ == "__main__":
API_KEY = "ragflow-VmNjkxYzhkOGI1OTExZWY4ZjBiMDI0Mm"
BASE_URL = "http://<my ip >/api/v1"
get_datasets(API_KEY, BASE_URL)
This is the output I received
Response status code: 200
Response content: <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="shortcut icon" href="/logo.svg">
<title>RAGFlow</title>
<link rel="stylesheet" href="/umi.f0c06456.css">
</head>
<body>
<div id="root"></div>
<script src="/umi.f6b0b739.js"></script>
</body>
</html>
Failed to decode JSON response.
I want to know if it's an error in the method I called, or if this interface has been invalidated?
I also used this URL
http://<my ip>/api/v1/dataset
This directly resulted in a 404
Response content: {"data":null,"retcode":100,"retmsg":"<NotFound '404: Not Found'>"}
me too, get in trouble now
import requests
headers = {"Authorization": "Bearer ragflow-djNTBjYjQwOGQzZjExZWY5NmJmMDI0Mm"}
res = requests.get(url="http://127.0.0.1:9380/api/v1/dataset",headers=headers)
print(res.text)
My code runs correctly. Please refer to the document http_api and python_api instead of ragflow_api.md. It may be because the Docker code is behind that on GitHub., which may be the reason for this error.
import requests headers = {"Authorization": "Bearer ragflow-djNTBjYjQwOGQzZjExZWY5NmJmMDI0Mm"} res = requests.get(url="http://127.0.0.1:9380/api/v1/dataset",headers=headers) print(res.text)My code runs correctly. Please refer to the document http_api and python_api instead of ragflow_api.md. It may be because the Docker code is behind that on GitHub., which may be the reason for this error.
Thank you for your reply. I tried it on my own computer and it ran successfully. However, the program on my server is still inaccessible, and I suspect it's due to a ragflow version issue or a Docker network connection problem. I will try to update the version. Thank you for your help.