langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
45.36k stars 6.38k forks source link

Could not resolve host: POST and invalid_param #7576

Open LeShan666 opened 3 weeks ago

LeShan666 commented 3 weeks ago

Self Checks

Provide a description of requested docs changes

Could not resolve host: POST and invalid_param

When using the official documentation's instruction for creating documents by file, you might encounter two errors: "Could not resolve host" which means the system was unable to find the host address, and "Invalid_param" which indicates that an invalid parameter was provided.

image

solutions: curl --location -X POST 'https://api.dify.ai/v1/datasets/{dataset_id}/document/create_by_file' \ --header 'Authorization: Bearer {api_key}' \ --form 'data={ "name": "Dify", "indexing_technique": "high_quality", "process_rule": { "rules": { "pre_processing_rules": [{ "id": "remove_extra_spaces", "enabled": true }, { "id": "remove_urls_emails", "enabled": true }], "segmentation": { "separator": "###", "max_tokens": 500 } }, "mode": "custom" } }' \ --form 'file=@"/data/leshan/file_upload_dify.txt"'

dosubot[bot] commented 3 weeks ago

@LeShan666 Hello there! 👋 I'm here to help you out with any bugs, questions, or contributions you have. I'm Dosu, a bot designed to assist you while you wait for a human maintainer.

To resolve the "Could not resolve host: POST" and "Invalid_param" errors, ensure the curl command syntax is correct. Here is the corrected command:

curl --location --request POST 'https://api.dify.ai/v1/datasets/{dataset_id}/document/create_by_file' \
--header 'Authorization: Bearer {api_key}' \
--form 'data={
    "name": "Dify",
    "indexing_technique": "high_quality",
    "process_rule": {
        "rules": {
            "pre_processing_rules": [{
                "id": "remove_extra_spaces",
                "enabled": true
            }, {
                "id": "remove_urls_emails",
                "enabled": true
            }],
            "segmentation": {
                "separator": "###",
                "max_tokens": 500
            }
        },
        "mode": "custom"
    }
};type=application/json' \
--form 'file=@"/data/leshan/file_upload_dify.txt"'

Replace {dataset_id} with your actual dataset ID and {api_key} with your actual API key. Ensure the file path "/data/leshan/file_upload_dify.txt" points to the correct file you want to upload. Note that the data form field should be correctly formatted as JSON and the type should be set to application/json [1][2][3][4][5].

To continue talking to Dosu, mention @dosu.

crazywoola commented 3 weeks ago

Feel free to open a pr for this.

totsukash commented 3 weeks ago

I encountered the same issue today and found this issue while searching. If it's alright with you, I'd be willing to create a PR. How does that sound?