Thijs
Thijs

Reputation: 1546

Method not allowed

Trying to upload a REST ext. to ML8. The error message is 'Method not allowed´ and this error comes from cURL. It's a 405 error.

The error is not clear enough for me. Not sure where to look for a solution. This should be straight forward and most code is copy/paste from the ML website or my templates..

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 reponse

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>

The REST ext.

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

function get() {

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

    return doc;
}

// Main
exports.GET = get;

ML Error

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"

Upvotes: 2

Views: 724

Answers (2)

I just used your sample javascript file and loaded it with the following command:

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'

This example comes from the documentation and works fine - even with ML 8.0. For this, I get a 204: Created

I suggest you use the sample curl command here and if it works, just re-factor it.

Upvotes: 2

joemfb
joemfb

Reputation: 3056

I'm not sure what could be causing that error precisely, but your cURL command looks a little odd: specifically, the quotes around your credentials, and the $URL variable before the actual target URL.

Try this command:

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'  

Upvotes: 1

Related Questions