Help! How to upload the metadata information of a document using Dify API? #21518
Replies: 1 comment
-
My previous API to create files directly with text also failed, and then I tried it and it worked. Save the input into the json_data variable I defined, and then call the create_by_text's API. json_data=$(jq -n curl -s |
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 wanted to upload the metadata information of a document in a dataset.



I already established a dataset and then I defined the metadata information as follow.
When I opened a document in the dataset which was established before I defined, it doesn't show any metadata information.
Then I used the following code to create a file with metadata information:
curl --location --request POST 'http://localhost:80/v1/datasets/17ff410c-8963-46bb-a457-78bf83ac5cb4/document/create_by_text'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer dataset-tDU3h856ibff3dfyDTEdQ5Qa'
--data '{
"name": "我的示例文档名称",
"text": "这是我文档的内容。它讨论了各种主题。",
"indexing_technique": "high_quality",
"process_rule": {
"mode": "automatic"
},
"doc_metadata": {
"title": "Dify API 介绍",
"author": "AI 助手"
}
}'
The response is:
{"document": {"id": "b0143a93-2534-45d4-a28f-67f1d4332c33", "position": 1158, "data_source_type": "upload_file", "data_source_info": {"upload_file_id": "4f4b2304-d817-4ce3-ae3d-72929109f7c0"}, "data_source_detail_dict": {"upload_file": {"id": "4f4b2304-d817-4ce3-ae3d-72929109f7c0", "name": "\u6211\u7684\u793a\u4f8b\u6587\u6863\u540d\u79f0", "size": 18, "extension": "txt", "mime_type": "text/plain", "created_by": "a2b79816-9b0c-4e51-983b-defbfc75308b", "created_at": 1750857238.689019}}, "dataset_process_rule_id": "9e280958-1432-45c4-9d4f-9aae8a6f0dbb", "name": "\u6211\u7684\u793a\u4f8b\u6587\u6863\u540d\u79f0", "created_from": "api", "created_by": "a2b79816-9b0c-4e51-983b-defbfc75308b", "created_at": 1750857239, "tokens": 0, "indexing_status": "splitting", "error": null, "enabled": true, "disabled_at": null, "disabled_by": null, "archived": false, "display_status": "indexing", "word_count": 18, "hit_count": 0, "doc_form": "text_model", "doc_metadata": null}, "batch": "20250625131358495411"}
"doc_metadata": null It showed that I failed to create a file with metadata.
2. Additional context or comments
Dify v1.4.3
started by docker compose
Beta Was this translation helpful? Give feedback.
All reactions