搜索Marklogic变换时出现Page Not Found错误

时间:2015-02-27 08:17:43

标签: rest marklogic

我正在尝试使用此link

中的示例在Marklogic中实现转换

当我尝试使用以下curl命令安装转换时

curl --anyauth --user admin:admin -X PUT -d@"./add-attr.xqy" -H "Content-type: application/xquery" 'http://localhost:8000/LATEST/config/transforms/add-attr?trans:name=string\?&trans:value=string\?'

它给了我错误(使用curl)

<div><h3>Message</h3><div style="width: 100%; height: 300px; overflow: auto;"><pre>&lt;error:error xsi:schemaLocation="http://marklogic.com/xdmp/error error.xsd" xmlns:error="http://marklogic.com/xdmp/error" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
&lt;error:code&gt;XDMP-BADREP&lt;/error:code&gt;
&lt;error:name&gt;err:FORX0004&lt;/error:name&gt;
&lt;error:xquery-version&gt;1.0-ml&lt;/error:xquery-version&gt;
&lt;error:message&gt;Invalid replacement string&lt;/error:message&gt;
&lt;error:format-string&gt;XDMP-BADREP: (err:FORX0004) fn:replace("/LATEST/config/transforms/add-attr", attribute{fn:QName("", "uri")}{"^/(common-api|dashboard|history|manage|nav|packaging|rest-apis)(..."}, &amp;lt;rest:uri-param name="url" xmlns:rest="http://marklogic.com/appservices/rest"&amp;gt;/LATEST/config/transforms/add-attr?trans:name=string\?&amp;amp;amp;trans...&amp;lt;/rest:uri-param&amp;gt;) -- Invalid replacement string: /LATEST/config/transforms/add-attr?trans:name=string\?&amp;amp;trans:value=string\?&lt;/error:format-string&gt;
&lt;error:retryable&gt;false&lt;/error:retryable&gt;
&lt;error:expr&gt;fn:replace("/LATEST/config/transforms/add-attr", attribute{fn:QName("", "uri")}{"^/(common-api|dashboard|history|manage|nav|packaging|rest-apis)(..."}, &amp;lt;rest:uri-param name="url" xmlns:rest="http://marklogic.com/appservices/rest"&amp;gt;/LATEST/config/transforms/add-attr?trans:name=string\?&amp;amp;amp;trans...&amp;lt;/rest:uri-param&amp;gt;)&lt;/error:expr&gt;
&lt;error:data&gt;
&lt;error:datum&gt;/LATEST/config/transforms/add-attr?trans:name=string\?&amp;amp;trans:value=string\?&lt;/error:datum&gt;

我甚至尝试使用 Postman-chrome app ,它给了我 401 Unauthorized 错误。

即使我正在使用

检查可用的变换
http://localhost:8000/v1/config/transforms

它给了我找不到页面例外enter image description here

我正在尝试使用具有所有管理员权限的 admin 用户

我在这里缺少什么?如何为REST调用构建转换?

1 个答案:

答案 0 :(得分:1)

我遇到了同样的错误,但前提是我对MarkLogic 7运行上述命令.MarkLogic 7没有在端口8000上运行REST-api,这是MarkLogic 8中的新功能。

除此之外,你应该使用url编码而不是regex转义为trans:xxx请求参数值中的问号,例如:

curl --anyauth --user admin:admin -X PUT -d@"./add-attr.xqy" -H "Content-type: application/xquery" 'http://localhost:8000/LATEST/config/transforms/add-attr?trans:name=string%3F&trans:value=string%3F'

HTH!