POST到_temp_view时出现CouchDB错误

时间:2015-09-11 14:32:19

标签: couchdb

我尝试在CouchDB上进行临时查看:

curl -X POST  'http://127.0.0.1:5984/blog/_temp_view' -d '{"map":"function (doc) {  emit(null, doc )  }"}' -H 'Content-Type: application/json' -H 'Authorization: Basic admin:admin'

并有错误:

{"error":"unknown_error","reason":"function_clause"}

在CouchDB日志中:

[Fri, 11 Sep 2015 14:30:02 GMT] [error] [<0.20879.6>] 

function_clause error in HTTP request
[Fri, 11 Sep 2015 14:30:02 GMT] [info] [<0.20879.6>] Stacktrace: [{base64,b64d_ok,
[bad],
[{file,"base64.erl"},{line,364}]},
{base64,decode,2,
[{file,"base64.erl"},{line,266}]},
{base64,decode,1,
[{file,"base64.erl"},{line,117}]},
{couch_httpd_auth,basic_name_pw,1,
[{file,"couch_httpd_auth.erl"},
{line,50}]},
{couch_httpd_auth,
default_authentication_handler,1,
[{file,"couch_httpd_auth.erl"},
{line,65}]},
{couch_httpd,authenticate_request,2,
[{file,"couch_httpd.erl"},{line,401}]},
{couch_httpd,handle_request_int,5,
[{file,"couch_httpd.erl"},{line,316}]},
{mochiweb_http,headers,5,
[{file,"mochiweb_http.erl"},{line,94}]}]

当我在富顿临时观看时

function (doc) {  emit(null, doc )  }

它运作良好。

我在Ubuntu 14.04上有CouchDB 1.6.1

我如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

因为那不是CouchDB处理授权的方式,如果您允许它或者您使用类似FTP的登录,您尝试在没有Authorization标头的情况下运行它:

curl -X POST  'http://admin:admin@127.0.0.1:5984/blog/_temp_view' -d '{"map":"function (doc) {  emit(null, doc )  }"}' -H 'Content-Type: application/json'

http://guide.couchdb.org/draft/security.html#authentication