将连续复制发布到Replicator DB活动

时间:2018-07-16 15:58:27

标签: c# couchdb

我正在用C#开发与CouchDB交互的应用程序。

目标是允许数据库的连续复制,但是,这需要在“复制器DB活动”选项卡中完成,而不是在传统的_replicate活动选项卡中完成,因为后者在服务停止或注销时会丢失。

到目前为止,我有以下代码:

var request = (HttpWebRequest)WebRequest.Create(replicateURL + "_replicator");

        request.Method = "POST";
        request.ContentType = "application/json";
        request.Timeout = Timeout.Infinite;
        request.KeepAlive = true;

        string json = "{  \"_id\": \"" + replicationName  + "\", " +
            "\"source\": {    \"url\": \""+ SourceName + "\"  },  " +
            "\"target\": {    \"url\": \"" + TargetName + "\"  },  " +
            "\"create_target\": true,  " +
            "\"continuous\": true } " ;
        try
        {
            using (var streamWriter = new StreamWriter(request.GetRequestStream()))
            {
                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }
            HttpWebResponse httpResponse = (HttpWebResponse)request.GetResponse();
...}

问题是,当我尝试获取响应时,我收到一个错误:

The remote server returned an error: (403) Forbidden.

有人知道如何将请求发布到Replicator DB Activity中吗?

0 个答案:

没有答案