-
Self Checks
1. Is this request related to a challenge you're experiencing? Tell me about your story.I can successfully call the backend API to create an empty knowledge base, but I get a 400 error as soon as I add retrieval parameters. I've tried constructing the JSON myself and also used the example request from the official documentation, but both failed. Where exactly am I going wrong with the parameters I'm passing? 2. Additional context or commentsAPI: /datasets The response: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hi @ZhegeMaw! I'm Dosu and I’m helping the dify team. The 400 BAD REQUEST error happens when the retrieval_model parameters in your request don't match the expected schema or contain invalid values. The backend uses strict validation: every field in retrieval_model must be present and correctly typed, and nested objects like weights and reranking_model must include required fields. For example, weights must have a weight_type (allowed values: "semantic_first", "keyword_first", "customized"), and reranking_model must use valid provider/model names recognized by Dify—using an unsupported provider like "Qwen" will trigger a 400 error source. Common causes include: malformed JSON, missing required fields (like weight_type in weights), incorrect enum values (search_method must be a valid option), or sending the request body as raw text instead of proper JSON source. Also, ensure your Content-Type header is set to application/json. Here’s a minimal example of a valid retrieval_model object: "retrieval_model": {
"search_method": "hybrid_search",
"reranking_enable": false,
"reranking_model": {
"reranking_provider_name": "",
"reranking_model_name": ""
},
"reranking_mode": null,
"top_k": 4,
"score_threshold_enabled": false,
"score_threshold": null,
"weights": {
"weight_type": "semantic_first"
}
}Double-check your JSON structure, required fields, and provider/model names. If you still get a 400 error, inspect the response body for a more specific message—sometimes it will say which field is invalid or missing source. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.


Hi @ZhegeMaw! I'm Dosu and I’m helping the dify team.
The 400 BAD REQUEST error happens when the retrieval_model parameters in your request don't match the expected schema or contain invalid values. The backend uses strict validation: every field in retrieval_model must be present and correctly typed, and nested objects like weights and reranking_model must include required fields. For example, weights must have a weight_type (allowed values: "semantic_first", "keyword_first", "customized"), and reranking_model must use valid provider/model names recognized by Dify—using an unsupported provider like "Qwen" will trigger a 400 error source.
Common causes include: malformed JSON, missing re…