Could not resolve host: POST and invalid_param #5185

Closed
opened 2026-02-21 18:09:47 -05:00 by yindo · 3 comments
Owner

Originally created by @LeShan666 on GitHub (Aug 23, 2024).

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

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"'

Originally created by @LeShan666 on GitHub (Aug 23, 2024). ### Self Checks - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### 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](https://github.com/user-attachments/assets/1c322e22-bb08-430a-85e8-ccbff3eda8af) 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"'
yindo added the 📚 documentation label 2026-02-21 18:09:47 -05:00
yindo closed this issue 2026-02-21 18:09:47 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 23, 2024):

@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.

@dosubot[bot] commented on GitHub (Aug 23, 2024): <!-- Greeting --> @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. <!-- Answer --> To resolve the "Could not resolve host: POST" and "Invalid_param" errors, ensure the `curl` command syntax is correct. Here is the corrected command: ```sh 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` <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/guides/knowledge-base/maintain-dataset-via-api.md)</sup><sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/jp/guides/knowledge-base/maintain-dataset-via-api.md)</sup><sup>[[3]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/knowledge-base/maintain-dataset-via-api.md)</sup><sup>[[4]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/features/datasets/maintain-dataset-via-api.md)</sup><sup>[[5]](https://github.com/langgenius/dify-docs/blob/main/jp/features/datasets/maintain-dataset-via-api.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Aug 23, 2024):

Feel free to open a pr for this.

@crazywoola commented on GitHub (Aug 23, 2024): Feel free to open a pr for this.
Author
Owner

@totsukash commented on GitHub (Aug 24, 2024):

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?

@totsukash commented on GitHub (Aug 24, 2024): 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?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5185