首页 > 解决方案 > 使用 HTTP 请求 CouchDB 3.0.0 检索文档

问题描述

我是 CouchDB 的初学者,在网上我读到可以使用 HTTP 请求运行 Mango 查询。我已经很努力了,但我无法处理这样的查询。

这是命令

C:\>curl -X POST http://root:root@127.0.0.1:5984/movielens/_find -d @query.json
{"error":"bad_content_type","reason":"Content-Type must be application/json"}

这是 json 文件的主体:

{"selector": { "Genres": {"$elemMatch": {"$eq": "Drama"}}}}

据我了解,我不知道我错在哪里。那么,我该如何运行这个查询呢?

标签: curlcouchdbcouchdb-mango

解决方案


您需要将Content-Type 标题中的 设置为application/json

尝试这个: curl -X POST http://root:root@127.0.0.1:5984/movielens/_find --header 'Content-Type: application/json' -d @query.json


推荐阅读