在 Couchdb ( 虹膜沙发 ) POST 请求中添加新文档失败,状态为 500

Adding a new document in Couchdb ( iriscouch ) POST request fails with Status 500

本文关键字:失败 文档 状态 新文档 Couchdb 沙发 POST 请求 添加      更新时间:2023-09-26

几个月前,下面的代码运行良好,用于在couchdb(iriscouch)中添加一个新文档。

现在我得到的是HTTP状态500。有解决方法吗?

代码(在节点.js中):

var http=require('http');
var options = {
  host: 'sbose78.iriscouch.com',
  path: '/bosedb1',
  method: 'POST',
  headers:{
 'Content-Type':'application/json',
 'accept':'application/json'
   }
 };
var data={
   'servings' : 4,
   'subtitle' : "Delicious with fresh bread",
   'title' : "Fish Stew------"
};
var req = http.request(options, function(res) {
   console.log('STATUS: ' + res.statusCode);
   console.log('HEADERS: ' + JSON.stringify(res.headers));
     var body="";
   res.on('data', function (chunk) {
     body+=chunk;
         console.log('BODY(inside listener):'n ' + body);
   }); 
  console.log('BODY (outside listener): ' + body);
});

req.on('error', function(e) {
  console.log('problem with request: ' + e.message);
});

 //write data to request body
req.write(JSON.stringify(data));
req.end();

回应:

    STATUS: 500
HEADERS: {"content-type":"text/plain","content-length":"239"}
BODY(inside listener):
 Internal routing error
Sorry, we cannot connect to the intended server.
We have just been notified of this problem. We will correct it as soon as possible.
Feel free to contact us if you have any questions: support@iriscouch.com

看起来 http://www.iriscouch.com/目前已关闭:

Host not found: www.iriscouch.com

你有没有考虑过使用抽象层,至少要做http?

  • 请求

如果你不:),你的代码库将有很多http代码

我个人编写和维护节点.js CouchDB 客户端,它是基于请求的,如果你对此感到好奇,你可以在 github 上找到更多信息