Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 运行CouchRest.put()时出错_Ruby_Couchdb - Fatal编程技术网

Ruby 运行CouchRest.put()时出错

Ruby 运行CouchRest.put()时出错,ruby,couchdb,Ruby,Couchdb,当我尝试在irb中运行命令时,我需要更新couchdb文档 CouchRest.put('http://localhost:5984/db', {"_id": "1","_rev": "sdf", "test": "testing"}) 我得到一个错误- RestClient::Request::Unauthorized:401 Unauthorized:{“error”:“Unauthorized”,“reason”:“您不是服务器管理员”。} 在同一控制台中,我能够成功运行- Co

当我尝试在irb中运行命令时,我需要更新couchdb文档

  CouchRest.put('http://localhost:5984/db', {"_id": "1","_rev": "sdf", "test": "testing"})
我得到一个错误-

RestClient::Request::Unauthorized:401 Unauthorized:{“error”:“Unauthorized”,“reason”:“您不是服务器管理员”。}

在同一控制台中,我能够成功运行-

  CouchRest.post('http://localhost:5984/db', {"test": "testing"})
谁能帮个忙吗


干杯

这一点很简单。API声明,针对db名称的PUT(在您的示例中为“db”)试图创建一个新的数据库,这需要管理员权限

要创建新文档,您可以像成功使用POST一样使用POST,但API文档不鼓励使用POST。PUTs可用于创建和更新

要更新现有文档,请在URL路径中使用带有文档ID的PUT,并在JSON中使用要更新的所需修订版本;e、 例如,
CouchRest.put('http://localhost:5984/db/1“,{rev:“sdf”,“test:“testing”})

有关更多信息,请参阅位于的API文档