如何使用Node使用摘要式身份validation来发布消息?

我正尝试使用节点将消息发送到具有摘要安全性的MarkLogic应用程序服务器。 等效的curl请求正常工作:

curl -v -X POST --anyauth -u admin:admin --header "Content-Type:application/json" \ -d '{"user-name":"joe", "password": "cool"}' http://localhost:8002/manage/v2/users 

我尝试使用NPM请求模块 ,它说它支持摘要请求。 我能够成功地做一个GET请求。 这是POST的一个尝试:

 request( { 'url': 'http://localhost:8000/manage/v2/users', 'method': 'POST', 'auth': { 'user': 'admin', 'password': 'admin', 'sendImmediately': false }, 'followRedirect': true, 'followAllRedirects': true, 'json': true, 'body': {'user-name':'joe', 'password': 'cool'} }, function(error, response, body) { console.log('callback: ' + response.statusCode); } ); 

这得到了我一个401.用户名和密码是正确的。 我也试过这样的:

 request .post( 'http://localhost:8000/manage/v2/users', {'user-name':'joe', 'password': 'cool'}) .auth('admin', 'admin', false) .on('response', function(response) { console.log('response: ' + JSON.stringify(response)); }) .on('error', function(error) { console.log('error: ' + error); }); 

这让我302.我觉得我一定在这里错过了一些简单的事情。

  • 节点v0.10.31
  • MarkLogic 8.0-2

这原来有一个简单的解决scheme:curl请求工作,因为我使用localhost:8002; 节点请求失败,因为我使用了localhost:8000。 咄。 302redirect告诉我使用8002,我只是错过了。

我很确定,当我遇到这个问题时,解决scheme是将应用服务器中的authentication设置从“摘要”更改为“digestbasic”。 (回答是因为我没有足够的代表来评论任何地方。)