方法不允许

Method not allowed

正在尝试上传 REST 分机。至 ML8。错误消息是“不允许的方法”,此错误来自 cURL。这是一个 405 错误。

这个错误对我来说不够清楚。不确定在哪里寻找解决方案。这应该是直截了当的,大部分代码是 copy/paste 来自 ML 网站或我的模板..

cURL

curl --anyauth --user 'thijs':'password' -X PUT -i -H "Content-type: application/vnd.marklogic-javascript" -d@"./plantinfo-ext.sjs" $URL'http://uien:8017/v1/config/resources/plantinfo?method=get'  

cURL 响应

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

HTTP/1.1 405 Method Not Allowed
Content-Type: text/html; charset=utf-8
Server: MarkLogic
Allow: DELETE, GET, HEAD, OPTIONS
Content-Length: 221
Connection: Keep-Alive
Keep-Alive: timeout=5

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>405 Method Not Allowed</title>
    <meta name="robots" content="noindex,nofollow"/>
  </head>
  <body>
    <h1>405 Method Not Allowed</h1>
  </body>
</html>

REST 分机

/**
 * @name plantinfo
 * This REST extentsion provides SOAP service for the shipment data
 */

function get() {

    doc = {'test': 'yes'};

    return doc;
}

// Main
exports.GET = get;

ML 错误

10.8.0.6 - thijs [09/Dec/2015:14:58:23 -0500] "PUT /v1/config/resources/plantinfo?method=get HTTP/1.1" 405 221 - "curl/7.35.0"

我不确定是什么导致了这个错误,但是你的 cURL 命令看起来有点奇怪:具体来说,你的凭据周围的引号,以及之前的 $URL 变量实际目标 URL.

试试这个命令:

curl --anyauth --user thijs:password -X PUT -i \
  -H "Content-type: application/vnd.marklogic-javascript" \
  -d@"./plantinfo-ext.sjs" \
  'http://uien:8017/v1/config/resources/plantinfo?method=get'  

我刚刚使用了您的示例 javascript 文件并使用以下命令加载它:

curl --anyauth --user admin:admin -X PUT -i \
-H "Content-type: application/vnd.marklogic-javascript"\
--data-binary @"./test.sjs"   \
'http://localhost:8000/v1/config/resources/example'

此示例来自文档并且工作正常 - 即使使用 ML 8.0。为此,我得到一个 204: Created

我建议你在这里使用示例 curl 命令,如果它有效,只需重构它。