使用REST api将文档摄取到marklogic中的未经授权的错误?

时间:2017-10-14 14:14:30

标签: curl marklogic marklogic-9

我正在使用从我的Windows机器上的REST APi到我已创建的数据库Test来摄取标记loglog的文档。

F:\Curl>curl --anyauth --user admin:admin -X PUT -d@"F:/REST/file.xml" -i -H "Content-type: application/xml" http://localhost:8000/Test/documents?uri=/xml/F:/REST/file.xml

但我得到的错误是这样的:

HTTP/1.1 401 Unauthorized
Server: MarkLogic
WWW-Authenticate: Digest realm="public", qop="auth", nonce="317cc2c17ace5b3680ddb90df7d7e4d9", opaque="871eddaeecdf779c"
Content-Type: text/html; charset=utf-8
Content-Length: 209
Connection: Keep-Alive
Keep-Alive: timeout=5

HTTP/1.1 404 Not Found
Content-type: text/html; charset=UTF-8
Server: MarkLogic
Content-Length: 5763
Connection: Keep-Alive
Keep-Alive: timeout=5

<!DOCTYPE html>
<html xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xs="http://www.w3.org/2001/XMLSchema"><head><title>Error ΓÇó MarkLogic Application Services</title><meta http-equiv="X-UA-Compatible" content="IE=8"/><!-- XSLTForm dependency --><link href="/common/static/css/environment-ui.css?9.0-2" media="screen" rel="stylesheet" type="text/css"/><link href="/common/static/css/universal-header.css?9.0-2" media="screen" rel="stylesheet" type="text/css"/><script src="/common/static/js/universal-header.js?9.0-2" type="text/javascript"> </script><script>var ML = ML || {};  ML.environmentUI = {};</script><script src="/common/static/js/environment-ui.js?9.0-2" type="text/javascript"> </script><link rel="stylesheet" type="text/css" href="/common/static/css/base.css"/><link rel="stylesheet" type="text/css" href="/common/static/css/master.css"/><link rel="stylesheet" type="text/css" href="/common/yui-2.8/menu/assets/skins/sam/menu.css"

我的curl语法有什么问题吗?

更新了卷曲命令:

F:\Curl>curl --digest --user admin:admin -X PUT -d@"F:/REST/rest.xml" -i -H "Content-type: application/xml" "http://localhost:8000/v1/documents?uri=/rest/file.xml" 

1 个答案:

答案 0 :(得分:2)

您正在使用Curl的anyAuth选项。这将尝试一种身份验证方法(基本),然后再次重试(摘要),如果前一个失败(依此类推,依此类推)。我讨厌anyAuth的样本,因为人们对结果感到困惑。最好知道服务器的期望并使用特定的auth方法。

仔细查看你的帖子..

第一个回复是Ún-authorized

然后cUrl重试并收到404 - 未找到。 - 身体反应实际上是一个网页..

所以,问题根本不是身份验证..

网址“http://localhost:8000/Test/documents?uri=/xml/F:/REST/file.xml”似乎根本不存在。我从来没有听说过AppServices(8000)服务器上的端点调用Test / documents。

此外,为了增加安全性,我建议将您的网址用双引号括起来,以保护可能在命令行上受到损坏的任何特殊字符。