如何通过Apache的HttpClient在Couchdb中设置管理员(给出一个curl示例) [英] How to setup administrators in Couchdb via Apache's HttpClient (given a curl example)
问题描述
所以我正在使用CouchDB Gui Toolbox,以便更轻松地在Android上维护CouchDB的设置,因为Futon在小型移动设备上非常不舒服.
So I am working on a CouchDB Gui Toolbox for easier maintaining an setting up CouchDB on Android, as Futon is quite uncomfortable on a small mobile device.
为此,我想坚持使用"org.apache.http.client.*"软件包,在我想设置管理员之前,它运行得很好.
I wanted to stick to the "org.apache.http.client.*" packages for this which was working out quite well until I wanted to setup administrators..
使用命令行工具"curl",它的工作原理就像一个魅力:
With the commandline tool "curl" it works like a charm:
curl -X PUT http://127.0.0.1:5984/_config/admins/username -d '"password"'
但是在将其转换为"org.apache.http.client.methods.HttpPut()"方法方面,我一直遇到很大的麻烦.
But I keep on having big problems translating that to a "org.apache.http.client.methods.HttpPut()" method.
任何帮助表示赞赏.
推荐答案
DefaultHttpClient client = new DefaultHttpClient();
HttpPut put = new HttpPut("http://127.0.0.1:5984/_config/admins/username");
put.setEntity(new StringEntity("\"password\""));
client.execute(put);
这篇关于如何通过Apache的HttpClient在Couchdb中设置管理员(给出一个curl示例)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!