Replies: 1 comment
-
|
To connect an external RagFlow Knowledge Base as a Dify external KB, your external API must accept POST requests at the /retrieval endpoint. Dify sends a POST request with a JSON body containing retrieval_setting (top_k, score_threshold), query, knowledge_id, and optionally metadata_condition. The request includes headers: Content-Type: application/json and Authorization: Bearer {API_KEY} if configured. The API must respond with a 200 status and a JSON object containing a records array, each with content, score, title, and optionally metadata. If your RagFlow endpoint only supports GET or a different path, you'll get a 405 error like you saw—Dify requires POST at /retrieval for external KBs to work reference reference. If RagFlow’s API doesn’t natively match this contract, you can use a gateway (like nginx+lua or a simple proxy) to translate Dify’s POST /retrieval requests to RagFlow’s expected format and method, and adapt the response back to Dify’s required structure reference. Make sure you’re using the correct port (e.g., 9380 or 8080, not 81), and that your proxy/firewall allows traffic on that port reference. After setup, use Dify’s Recall Test to verify retrieval. If you change the API key or config, delete and recreate the external KB in Dify to refresh the connection. If your external KB doesn’t require an API key, set up a proxy to strip the Authorization header from Dify’s requests before forwarding reference. If you need a concrete example of the expected request/response or a sample proxy config, let me know! To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Self Checks
1. Is this request related to a challenge you're experiencing? Tell me about your story.
I used below below external KB api and KB base setting.
##########################################

But when I did a retrival test, the web page throw below error.
<title>405 Not Allowed</title>405 Not Allowed
nginx/1.24.0 (Ubuntu)
I checked the ragFlow and it actually did not receive any KB request.
<title>405 Not Allowed</title>I also get the below error log in dify docker api error logs
######################################################
2026-01-13 14:19:28.151 ERROR [Dummy-733] [app.py:875] - Exception on /console/api/datasets/26d59f55-248b-4d15-8687-a0421413b44c/external-hit-testing [POST]
Traceback (most recent call last):
File "/app/api/controllers/console/datasets/external.py", line 299, in post
response = HitTestingService.external_retrieve(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/services/hit_testing_service.py", line 126, in external_retrieve
all_documents = RetrievalService.external_retrieve(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/rag/datasource/retrieval_service.py", line 130, in external_retrieve
all_documents = ExternalDatasetService.fetch_external_knowledge_retrieval(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/services/external_knowledge_service.py", line 328, in fetch_external_knowledge_retrieval
raise ValueError(response.text)
ValueError:
405 Not Allowed
nginx/1.24.0 (Ubuntu)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
<title>405 Not Allowed</title>File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/api.py", line 404, in wrapper
resp = resource(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view
return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/resource.py", line 41, in dispatch_request
resp = meth(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/app/api/controllers/console/wraps.py", line 220, in decorated
return view(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/app/api/libs/login.py", line 80, in decorated_view
return current_app.ensure_sync(func)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/controllers/console/wraps.py", line 37, in decorated
return view(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/app/api/controllers/console/datasets/external.py", line 309, in post
raise InternalServerError(str(e))
werkzeug.exceptions.InternalServerError: 500 Internal Server Error:
405 Not Allowed
nginx/1.24.0 (Ubuntu)
2. Additional context or comments
No response
Beta Was this translation helpful? Give feedback.
All reactions