Method Not Allowed response when creating design document via REST API

Community Edition 5.0.1 build 5003, Docker deployment

$ curl -i -X PUT -H "Content-Type: application/json" http://Administrator:password@ -d @doc.json 
HTTP/1.1 405 Method Not Allowed
X-XSS-Protection: 1; mode=block
X-Permitted-Cross-Domain-Policies: none
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Server: Couchbase Server
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Date: Mon, 02 Apr 2018 17:54:59 GMT
Content-Type: text/plain
Content-Length: 18
Cache-Control: no-cache,no-store,must-revalidate

Design doc file:

$ cat test.json 
  "_id" : "_design/dev_test",
  "views" : {
    "test" : {
      "map" : "function (doc, meta) { if (doc.type == \"test\") { emit(, null); } }"

Can you help me to find an issue?

Thank you.

There are two issues here:

  1. The incorrect port 8091 is being used, the View Engine uses 8092:
curl -i -X PUT -H "Content-Type: application/json" http://Administrator:password@ -d @doc.json
Warning: Couldn't read data from file "doc.json", this makes an empty POST.
HTTP/1.1 400 Bad Request
Server: MochiWeb/1.0 (Any of you quaids got a smint?)
Date: Tue, 03 Apr 2018 12:31:13 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 88
Cache-Control: must-revalidate

{"error":"bad_request","reason":"invalid UTF-8 JSON: {{error,insufficient_data},<<>>}"}
  1. Even with that change the Design Document will not be created as the file is called test.json but the curl is using -d @doc.json, that is why a invalid UTF-8 JSON error is produced.

This should work:

curl -i -X PUT -H "Content-Type: application/json" 
http://Administrator:password@ -d @test.json


HTTP/1.1 201 Created
Server: MochiWeb/1.0 (Any of you quaids got a smint?)
Date: Tue, 03 Apr 2018 12:46:41 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 36
Cache-Control: must-revalidate